YUI Compressor

The YUI Compressor is another tool similar to Dojo ShrinkSafe, that we can use to minify JavaScript. It can also be used to minify CSS files.


If you want to use YUI COmpressor first you should download it from here. Then you use it using command line tool.



  • You can use following syntax to compress test.js into test.min.js

    java -jar yuicompressor-***.jar -o test.min.js test.js

    It seems that YUI Compressor does nto support combining multiple files into one, instead you will have to use either cat command on linux or copy command on windows to combine multiple files into one and then use YUICompressor to minify the resultant file

  • You can use the YUI COmpressor to compress the CSS files too, it depends on the file extension to figure out if its .js or .css file and takes care to minify it accordingly

    java -jar yuicompressor-***.jar -o test.min.css test.css


    But if you want you can also specify the the --type command to specify the type of file you want to compress, so the syntax for compressing CSS file would be like this

    java -jar yuicompressor-***.jar --type css -o test.min.css test.css




Take a look at YUI compressor help page for details on the command line option