Why do people minify css and javascript, when we have gzip?

Silver Light picture Silver Light · Apr 24, 2013 · Viewed 13.1k times · Source

Why people go through all the pain of minifying JavaScript and CSS files if they can just turn on gzip compression on the web server? This will give the same (or even better) result in traffic preformance.

Does minification give additional benifits?

Answer

Pete picture Pete · Apr 24, 2013

You can use gzip (which is usually built into web servers) in combination with Minification. Minification does a lot of additional things that gzip can't, however, like removing comments, renaming long variables to shorter variable names, etc.

The resulting transferred data can be signicantly smaller than simply gzipping the original .js. It depends, obviously, on the source .js.

You can check out Compressorater(http://compressorrater.thruhere.net/). You can throw in your .js and it will minify using a variety of libraries with and without gzip and show you the results. You can see the comparion between simply gzipped and gzipped + minified by the various libraries.