5 ms·
> Lots of sites will minify and concatenate their JS, after all. Most with absolutely zero data to back up that it provides any sort of useful improvements to
by josteink 13y ago
> Lots of sites will minify and concatenate their JS, after all.
Most with absolutely zero data to back up that it provides any sort of useful improvements to justify the difficulties it introduces in debugging.
Considering how almost all web-servers and browsers support HTTP compression, minification is mostly a cargo-cult ritual.
- AlisdairO 13y agoFWIW, I'm making a site at the moment and very similar thoughts entered my head, so I tested it out. Minification + gzip (at best compression level) beat out just gzip by ~ 20%. I don't actually have that much JS so it's not really that important, but just thought it was worth a mention.
- Cthulhu_ 13y agoI never actually gave much thought into whether or not to minify JS or not, thanks for that insight. I'd definitely still concatenate files though; I have one project that has like 150 JS files and another 100 html templates (single page webapp), and there's a very tangible performance difference concatted vs. unconcatted.
- mping 13y agoThis isn't a problem if you generate source maps. Of course, if you have to support and debug old browsers, it's a different story. A quick google search got me to SO: http://stackoverflow.com/a/807161 http://stackoverflow.com/a/807161 results seem pretty significant. Besides, the worse your connection is, the more you will appreciate these techniques.
- byroot 13y agoAs much as I would like your statement to be true: jquery-2.0.3.js 236K jquery-2.0.3.js.gz 70K jquery-2.0.3.min.js 82K jquery-2.0.3.min.js.gz 29K Minification pay off a lot even with compression.
- michaelmior 13y agoTo be fair, this doesn't show a performance improvement, it shows a file size reduction. Of course you can assume one leads to the other, but it doesn't fully prove the point.
- byroot 13y agotime curl http://code.jquery.com/jquery-2.0.3.js > /dev/null real 0m0.433s time curl http://code.jquery.com/jquery-2.0.3.min.js > /dev/null real 0m0.210s Is it proved now ? Edit: Off course I didn't ran these requests only once.
- bct 13y agoThe obvious next question is "can't you achieve the same thing with gzip": time curl http://code.jquery.com/jquery-2.0.3.js > /dev/null 236k bytes real 0m0.432s time curl http://code.jquery.com/jquery-2.0.3.min.js > /dev/null 83612 bytes real 0m0.323s time curl http://code.jquery.com/jquery-2.0.3.js --compressed > /dev/null 87509 bytes real 0m0.273s time curl http://code.jquery.com/jquery-2.0.3.min.js --compressed > /dev/null 34066 bytes real 0m0.215s I think that people should be more skeptical of the complexity introduced by things like minification, but the advantages are pretty clear, even with compression.
- michaelmior 13y agoThis still doesn't show that actual site performance is improved. Also, gzip is not enabled on that server, so I think it's a less realistic scenario. I'm certainly being pedantic, but I've run into similar surprises before.
- ollysb 13y agoSprockets come's as standard with rails. In development the files are served separately, for easy debugging, but then they're minified/concatenated automatically for production.
- driverdan 13y ago> Most with absolutely zero data to back up that it provides any sort of useful improvements While it depends on a lot of factors, generally speaking minification is a good thing especially for mobile. There's really no downside in doing it (see next point). > justify the difficulties it introduces in debugging What difficulties? You should use a build process that minifies for your production site but not for testing. If you need to debug the live, minified files you can use source maps[1]. 1: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/ http://www.html5rocks.com/en/tutorials/developertools/source...