This new version of the YUI Compressor supports
stdout. This means that you can now call the YUI Compressor using the following command line:
java -jar yuicompressor-2.2.jar --type js < input.js > output.js
You can still use the following syntax as well:
java -jar yuicompressor-2.2.jar -o output.js input.js
This has three main consequences:
- All informational and error messages are now printed to
- If no input file is specified, the YUI Compressor defaults to
stdin. In that case, you must specify the
- If no output file is specified, the YUI Compressor defaults to
stdout(in prior versions, it used to create a file named after the input file, and appended the
The other main feature brought by this new version of the YUI Compressor is the support for JScript conditional comments:
/*@cc_on /*@if (@_win32) document.write("OS is 32-bit, browser is IE."); @else @*/ document.write("Browser is not 32 bit IE."); /*@end @*/
Note that the presence of a conditional comment inside a function (i.e. not in the global scope) will reduce the level of compression for the same reason the use of
with reduces the level of compression (conditional comments, which do not get parsed, may refer to local variables, which get obfuscated) In any case, the use of Internet Explorer’s conditional comments is to be avoided.
Finally, a few improvements have been made to the CSS compressor.