3 ms·
Better JavaScript Minification
- Groxx 17y agoTitle should probably be "Better JavaScript Minification with YUI". It's just about ways to hack around YUI to improve its compression (ie, what to avoid, because it trips up YUI). Or, ya know, you could just use another library. Like Closure: http://code.google.com/closure/ http://code.google.com/closure/ (anyone used Closure? Know how good it is?)
- axod 17y agohttp://axod.blogspot.com/2010/01/google-closure-compiler-advanced-mode.html http://axod.blogspot.com/2010/01/google-closure-compiler-adv... In my tests, it's extremely good. It requires some effort to get things working with the advanced mode, but it's worth it to make things load quicker. Certainly far better than YUI.
- TeHCrAzY 17y agoI've had it break (without generating any warnings) some javascript just this morning using the simple mode (haven't had the time to sit down and look at exactly what was broken). So I would urge a great deal of caution in using it: test, test, test!
- axod 17y agoI haven't seen any issues with simple mode, but I would echo that. It can seriously mess things up if anything goes slightly wrong, so you need rigorous testing in place. Advanced mode can remove code you're using, it can rewrite variables you don't want rewritten, etc so you need to be sure everything is understood before you start. But the rewards are worth it... No compression: 92K, YUI: 56K, Closure Advanced: 47K.
- rgrove 17y agoThese tips are also very useful for Closure in simple optimizations mode. It's about avoiding things that can't be optimized safely, not avoiding things that "trip up" the compiler. Of course, Closure in advanced optimizations mode will require you to do a great deal of work to avoid tripping up the compiler.