[wp-hackers] Re: Packing JavaScript

Christian Höltje docwhat+list.wp.hackers at gerf.org
Tue Sep 18 13:45:16 GMT 2007


Compressing the JS definitely would be a win.

The best safe compressor I know of at the moment is Julien Lecomte's
YUI compressor.

Don't be fooled by it's name, it works for anything.

The way it works is it uses a JavaScript interpreter to build a parse
tree of the JavaScript and writes out the JavaScript again.

This allows it to safely interpret the JavaScript and therefor safely
write it back out.

In addition it can now do safely do variable renaming since it knows
the scope of variables.  It can tell if the scope of a variable is
outside the code it is compressing and then not rename it.

In tests that I have seen and the few informal ones I have done, YUI
Compressor performs better than any of the other minifiers I have
seen.

http://www.julienlecomte.net/blog/2007/08/13/introducing-the-yui-compressor/

Ciao!

-- 
He who has imagination without learning has wings but no feet.
	 -- Joseph Joubert

The Doctor What: "What, Doctor What"             http://docwhat.gerf.org/
docwhat *at* gerf *dot* org                                        KF6VNC


More information about the wp-hackers mailing list