February 18, 2010
It's simple but powerful.
The project and code: YUICompressor CFC @ RIAForge
There is some sample code included with the download package.
author: Tom de Manincor
This CFC allows you to use the YUI Compressor Java library.
comments and white-spaces, obfuscates local variables using the smallest
possible variable name. This obfuscation is safe, even when using constructs
such as 'eval' or 'with' (although the compression is not optimal is those
cases) Compared to jsmin, the average savings is around 20%.
The YUI Compressor is also able to safely compress CSS files. The decision
on which compressor is being used is made on the file extension (js or css)"
This CFC adds some more flexibility. It accepts an input string or a file, as long as its valid JS or CSS.
You can also choose to return the compressed results back as a string or a file.
It is using the YUI components for both CSS and JS.
For more information on the YUI library visit:
ColdFusion 7 or Higher
YUI Compressor Java Library (version 2.4.2 included)
The constructor (init method) is required if using inheritance (ClassLoaderAdapter).
Since this is dependent upon the YUI Java library,
I have integrated a ClassLoaderAdapter that allows you to toggle between JavaLoader
or the CF native ClassLoader that will use libraries found in your CF class path.
Remember, if you are not going to use JavaLoader then make sure you put the yuicompressor-2.4.2.jar in your CF class path.
If this is the approach you choose you also have the option to discard the ClassLoaderAdapter.
Instead of using the YUICompressor.cfc and the ClassLoaderAdapter.cfc, rename and use the included YUICompressor_noinheritance.cfc.
Do not use the additional libraries that are bundled with the base jar. String Index out of range errors may occur.
0.1 -INITIAL RELEASE- 2/18/2010
-JS and CSS compression supported
-auto detect input type
-allow input files or string
-output to file or string