Tagyuicompressor

Google Closure Tools

Some days ago, Google released the Google Closure Tools, that look very promising. I’ve yet been unable to feel particular enthusiasm for the Google Closure Library which seems like just another JavaScript (-only)? libary, something that may only be of any importance because it’s coming from Google, but who does not seem to provide anything really spectacular or new.

The Closure Compiler, however looks really good. It’s not only a simple script compressor, but also offering dead code removal and lint-like feature. I’ve been doing some testing with our main JavaScript bundle(all JavaScript code used in our test application concatenated together):

Description Bytes abs Bytes %
js bundle 284935 100,0%
yuicompressor compressed 126656 44.5%
closure compiler compressed 97362 34.2%
js bundle gzip 75163 26.4%
yui + gzip 42189 14.8%
closure + gzip 35432 12.4%

As you can see, Closure compiler is a bit better than yuicompressor. The only downside to it is that it doesn’t support IE conditional comments. This means that above numbers a little too good for Google Closure as we are using some IE conditional comments for compatibility purposes.

The depedency management looks promising, too. So far I am using a self-brew solution for my current project at work, but I would really like to see a standard for packaging, compression and deployment for Javascript.

YUIZilla Compressor

After again spending time to fix issues resulting from a collision of the yuicompressor jar and the normal rhino jar in one of my projects, I came up with a more radical solution:

  1. Download the source codes from yuicompressor and the corresponding rhino release
  2. Replace every occurance of “mozilla” with “yuizilla”
  3. PROFIT!

 So now I have a version of the yuicompressor that works fine and does not conflict with the rhino version I also have in my project. And I don’t need any stupid jar class loaders or have to write stdin/stdout handling for some terribly slow external yuicompressor process. I can just use the classes

  • com.yahoo.platform.yui.compressor.CssCompressor
  • com.yahoo.platform.yui.compressor.JavaScriptCompressor 

and be done with it. Hurray for fast dynamic server-side script and style compression!

© 2014 fforw.de

Theme by Anders NorenUp ↑