Buried in the jquery 1.4 release announcement, under the Miscellaneous section, is the following tidbit:
Now use Closure Compiler instead of YUI Min (commit)
So what is Closure Compiler? According to the project page at Google Labs,
According to the commit message, switching from YUI Compressor to Google Closure Compiler reduced the filesize by 13% with no other changes.
But wait, there's more!
A 13% bump is not bad, and certainly no one is surprised these days when Google one-ups Yahoo. But it gets better: jquery is so far only using Closure Compiler in Standard Optimizations mode (the default setting). It is not yet using the more aggressive Advanced Optimizations. With advanced optimizations enabled, Closure Compiler also:
- renames global variables and function names to make them shorter,
- removes unused functions, and
- inlines references where possible, including function calls, constants, and variables.
The catch is...
In order to use Advanced Optimizations safely, you need to tell Closure Compiler which symbols are actually calls to external code (externs) and which symbols need to be preserved as public API so that other libraries can reference them (exports). In the case of exports, it still shortens the symbol names everywhere they are used, but it sets up a single alias with the public name.
Setting up externs and exports takes time, effort, and testing, and it's probably the reason why jquery isn't using advanced optimizations just yet. Still, the source code is out there in plain sight and anyone can do it. So it's only a matter of time before jquery gains some of the same compiler optimizations that lend GWT its performance advantage.