Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Rails app using the Rails javascript helpers to concat all the javascript together into a single file.

In addition my web server is serving this javascript file to the end users as gzip compressed.

As modern browsers will request the compressed version - is there any real benefit to me bothering to minify the javascript on each deploy? I'm sure it will save some bandwidth but will it be worth it if the content was already compressed.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

That depends on your definition of "worth it" is, obviously. I have a rather large JS file in a project:

  • Original state: 41.7 kB
  • Minimized with YUI compressor: 27.8 kB (~67% of non-minimized)
  • Non-minimized, gzipped (with 7-zip/"normal" compression level): 10.8 kB (~26% of original)
  • Minimized and gzipped: 7.45 kB (~18% of original, ~69% of gzipped/non-minimized)

YMVV, but as we see, the relative size of a minimized to a non-minimized file is about the same even after gzipping (approximately two thirds). I balanced those 3 kBs I'd gain by minimizing against the weight of the rest of the page (== considerable), and decided against bothering with minimization.

Minimization does give your developers an advantage, though - as it strips out comments, you sprinkle the code with bug notices, explanations for kludges or complaints about stupid customers, lusers, management, etc, without risking embarrassment if someone does a View Source.

share|improve this answer
    
Actually, I checked and with minification I reduced my JS from 180k/61.5k (uncompressed/compressed) to 101k/37k. I figure a 25k saving is probably worth it overall for the hour it took me to get minification running on deploy. –  davidsmalley Aug 20 '09 at 11:34

Also, minimification helps when there is a user coming to your site through a proxy, as that sometimes prevents the use of GZIP compression.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.