Ever wonder which JavaScript compressor you should use? Or which one can crunch your code down to the smallest size?
The “CompressorRater” allows you to easily play with several of the most popular freely available JavaScript Compressors on your own code, from one web interface.
You can quickly view how much compression all the tools give you both with and without gzip compression, and also view the compressed results directly.
You can also view some statistics of CompressorRater runs against the code in several popular JavaScript libraries. (Note that the compressed output of these libraries has not been tested and may not work. Before switching from a given sanctioned compressor on a given library, make sure you run through all the unit tests for that given library, using the compressed JavaScript!)
The following compression tools are rated:
- JSMin is a conservative compressor, written several years ago by Douglas Crockford. It is considered safe (especially if you verify your code with JSLint first– an excellent thing to do anyway) because it doesn’t attempt to change any variable names.
- Dojo shrinksafe is a very popular Java based JavaScript compressor that parses the JavaScript using the rhino library and crunches local variable names.
- Packer by Dean Edwards, is also a very popular JavaScript compressor, that can go beyond regular compression and also add advanced on-the-fly decompression with a JavaScript runtime piece.
- the YUI Compressor is a newer compressor written by Julien Lecomte, that aims to combine the safety of JSMin with the higher compression levels acheived by Dojo Shrinksafe. Like Dojo shrinksafe, it is written in Java and based on the rhino library.
When a given compression tool has options that you can set to tweak the compressed output, all possible combinations of options are run to show you the effects of the size differences when using those different options. Your compressed results are also viewable under all possible compressor options.
While this tool allows you to quickly test out the different Compressors, you must be sure to test your resultant compressed code diligently because JavaScript compressors aren’t perfect and can introduce subtle bugs.
Using JSLint to clean up your JavaScript code is always a great idea, and I’ve found that it can make your code work much better with any of the compressors.
I hope you find this tool useful! Check back often, because I plan to add some neat new features soon. I’m also looking forward to constructive criticism and comments on how I can improve the tool.
The CompressorRater is located at http://compressorrater.thruhere.net/