is jQuery 1.4.2 compatible with Closure Compiler?
This is the code I use.
// ==ClosureCompiler== // @compilation_level ADVANCED_OPTIMIZATIONS // @output_file_name default.js // @code_url http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js // ==/ClosureCompiler==
And as far as I know you get the real benefit of Closure Compiler if you include the library with your code also, so it removes the unused functions. Yet my testings show that I can't get any further than compressing the library itself..
What am I doing wrong? Any kind of insight will be much appreciated.
jQuery 1.4 is compatible with the Closure Compiler, but only with the SIMPLE_OPTIMIZATIONS setting. The official minified version of jQuery is actually compiled with this setting, and this reduces the file size by 13%. Quote from this commit comment by John Resig:
Switched from using YUI Compressor to Google Compiler. Minified and Gzipped filesize reduced to 22,839 bytes from 26,169 bytes (13% decrease in filesize).
jQuery is not compatible (yet) with the Closure Compiler in advanced mode. I agree it would be a very good thing to make it compatible, because its method-chaining syntax lends very readily to prototype virtualization for much improved execution speed.