zefer / Combine

Serves Combined & compressed js & css with caching, using ColdFusion
11 stars 7 forks source link

License

Copyright 2009 Joe Roberts

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Combine.CFC

Combine multiple javascript or CSS files into a single, compressed, HTTP request.

Allows you to change this:

<script src='file1.js' type='text/javascript'></script>
<script src='file2.js' type='text/javascript'></script>
<script src='file3.js' type='text/javascript'></script>

To this:

<script src='combine.cfm?files=file1.js,file2.js,file3.js' type='text/javascript'></script>

...combining and compressing multiple javascript or css files into one http request.

How do I use it?

  • If you want to use the CSS or Javascript compression, you need to add the required Java to your classpath. See "How to add the Java to your classpath" below...
  • Caching

    Combine caches the generated

    How much?

    Nowt! If you find this project worthy of a donation, please visit my Amazon wishlist http://www.amazon.co.uk/gp/registry/3JVC6BNDZP81B

    Using JavaLoader to load the Java objects

    By using Mark Mandel's JavaLoader, you can avoid having to place the .jar files in the class path, which can be fiddly, or even restricted on some shared hosting platforms.

    1. Download JavaLoader http://javaloader.riaforge.org/
    2. Tweak combine.cfm to pass in an instance of JavaLoader.cfc, and the path to the directory where you have placed the .jar files included with Combine.

    How to add the Java to your classpath [required for css and js compression, unless you use JavaLoader]

    1. Determine where you will place your Java, it must go in a directory in your Coldfusion class path. This could either be cf_install_dir\lib, or a custom directory path which has been added to the Coldfusion class path (through Coldfusion's admin/config)
    2. Add the code to the class_path_dir as determined in step 1. Copy combine.jar and yuicompressor.x.x.x.jar to your class_path_dir.
    3. Restart your CFML server

    Why?