Example of using Closure Compiler to attain an 85% improvement over YUI Compressor when minifying Closure Library code

I felt that a number of blog posts that I read on the Web dramatically underestimated Closure's ability to minify JavaScript, so I ran some tests that demonstrate how dramatic the effects of using the Compiler and the Library together can be. Bear in mind that most JavaScript code, as it is exists today, is not written in such a way that is compatible with the Compiler's Advanced mode, but the code in the Closure Library is. To learn how to update your code to work with Advanced mode, read the Advanced Compilation and Externs article on the Google Code web site.

These tests were run using the following software:

Here are the results:

Size in bytesFilename 
34291 awesomebar-advanced-no-debug.js Closure Compiler with ADVANCED_OPTIMIZATIONS enabled, along with some additional CompilerOptions. See DebugStrippingCompilerRunner.
37714 awesomebar-advanced.js Closure Compiler with ADVANCED_OPTIMIZATIONS enabled.
193986 awesomebar-simple.js Closure Compiler with SIMPLE_OPTIMIZATIONS enabled.
223693 awesomebar-yui.js YUI Compressor
261322 awesomebar-whitespace-only.js Closure Compiler with WHITESPACE_ONLY enabled.
809709 awesomebar-concat.js All of awesomebar.js's dependencies concatenated together. This file was used as the input to YUI compressor whereas the Closure Compiler received each dependency as an individual input.

Doing the math:

(1 - (34291 / 223693)) * 100% = 84.67% Savings

The code is publicly available on Google Code if you want to try running the tests yourself.

If nothing else, this should serve as an example of how to use the Compiler and calcdeps.py from an Ant build file, as well as an example of how to extend CompilerRunner to enable additional optimizations.