-
Notifications
You must be signed in to change notification settings - Fork 7
zefer/Combine
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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? ---------------- - Place combine.cfm and Combine.cfc somewhere under your webserver - Modify the combine.cfm with your preferred combine options, and error handling if required. - Update your <script> and <link> urls for JS and CSS respectively, e.g: - <script src="combine.cfm?type=js&files=monkey.js,jungle.js" type="text/javascript"></script> - <link href="combine.cfm?type=css&files=monkey.css,jungle.css" type="text/css" rel="stylesheet" media="screen" /> - [optional] copy the 'com' directory and contents to your class path (directory structure must not change) - required if you want to use the CSS or Javascript compression. Why? ---- - Reduces the number of HTTP requests required to load your page. All your javascript files can be combined into a single <script> request in your html file. - Compressing the CSS/JS reduces the filesize, therefore reduces the bandwidth overhead - Keep seperate CSS and JS files for easier development How does it work? ----------------- - [optional] Uses the dependable JSMin method to reduce redundancy from the JavaScript, without obfuscation. In my experience, it's very dependable. - [optional] Uses the YUI CSS compressor to reduce redundancy from the CSS, not just white-space removal, see http://developer.yahoo.com/yui/compressor/ - [optional] Caches merged files to local machine to avoid having to rebuild on each request - [optional] Uses Etags (file hash/fingerprints) to allow browsers to make conditional requests. E.g. browser says to server, only give me the javascript to download if your etag is different to mine (i.e. only if it has changed since my last visit). Otherwise, browser uses it's locally cached version. More ---- - You may also see benefits from enabling gzip compression on your webserver. You may find with gzip enabled, the compression of CSS and JS files via combine.cfc is of limited additional benefit (have you ever tried zipping a jpeg?). Experimentation should help you make this call. - YSlow is a great Firefox extension which can help you determine what optimisations you can make to imporve your site's performance (requires Firebug) - Firebug - It's pains me to think of the days I spent as a web developer without this Firefox extension! - The following post contains useful information about the Java class path: http://weblogs.macromedia.com/cantrell/archives/2004/07/the_definitive.html Credits ------- All I have done here is pulled together some other peoples' clever work, into a workable solution for Coldfusion apps. So loads of credit to the following: - Combine.php - A lot of ideas came from this project. Ed Eliot (www.ejeliot.com), Thanks! - JSMin: - Originally written by Douglas Crockford www.crockford.com - Ported to Java by John Reilly http://www.inconspicuous.org/projects/jsmin/JSMin.java - YUI CSS Compressor: - Part of the impressive YUI Compressor library http://developer.yahoo.com/yui/compressor/
About
Serves Combined & compressed js & css with caching, using ColdFusion
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published