Helping Your JavaScript Compressor Along
February 11th, 2008 | JavaScript, Web Development
Nicholas Zakas has some tips on optimizing your JavaScript code for compression over at the YUI blog today. It is written specifically for helping the YUI Compressor better compress your code, but general tips such as “Using constants for repeated values” are good for decreasing your file size no matter which compressor you are using.






1 comment so far ↓
It’s worth noting that those tips will make code slightly more readable in some cases (e.g. if local var is introduced for long chain of properties - so human eye doesn’t have to read chain again and again) and less readable in other cases (e.g. if constant is replaced with var).
It’s questionable whether 10% gain in compressed size worth the decrease of managebility of the code (unless you use your scripts on google or yahoo front page).
In all other cases, I think we should forget about file size at expense of input file readability. We are using this JavaScript Obfuscator: http://www.stunnix.com/prod/jo/ that even increases file size, sometimes a lot, in order to make code less readable, and are quite happy.
Leave a Comment