Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
An Argument Against JavaScript Minification (kevinsookocheff.com)
25 points by soofaloofa on May 10, 2011 | hide | past | favorite | 19 comments


Minification is vital. It has been widely reported that an extra 100ms in latency costs Amazon 1% of their sales. Google found that 500ms of extra latency reduced traffic by 20%. Optimising page load time is one of the cheapest and simplest ways of improving user experience and so your business.

Sacrificing profits and UX for a few hypothetical developers is lunacy. If you really want to share the wealth and let newbie developers read your source, blog about it or submit it to Github - then you can include explanation of your design and make it far easier for them to get the interesting bits.


When you're not relying on 200k of external libraries minification is a lot less significant.

When you enable GZIP it's even less so.


Minification still offers a substantial savings. The following file size stats are from jquery 1.6.0 just now pulled from google's urls:

Uncompressed (normal:minified) 232651:90518

Gzip -6 (normal:minified) 66778:31610

Gzip -1 (normal:minified): 81986:36633

gzip -9 only saves a few hundred bytes on each vs default compression level of 6.

bzip2 and xz do not achieve dramatic reductions of the readable jquery code either; the normal:minified ratio is slightly improved, but is still approx. 2:1.


When you're not relying on 200k of external libraries minification is a lot less significant.

Is that so. Tell me what else you know about the scope of my web application.


In some cases minification is absolutely vital.

Yet there are so many neat JavaScript tricks used on throwaway or one-off projects that are minified without reason.


This sounds more like an argument for open source. Ignoring efficiency issues, I'd much rather view a JavaScript framework on GitHub than in a View Source window.


If you want to share your code with others, open source it. There's no need to not-minify it so they can see it.

I don't see this an an anti-minification argument at all. Instead, it's an argument for open source in disguise.


Absolutely. While I'm more on the 'information wants to be free' side of things, I'm not sure what the ethics are of borrowing from some other sites JS. If it's really just to learn then fine, but how much copy/paste before you're in need of a license?


Copy and paste? Any! Learning from the code is one thing, but just taking it is wrong and illegal.


Here's how I do it: minified versions are used in the site, if someone wants to see my code, they can remove the "min" part:

used on site: http://laserey.es/media/javascripts/base.min.js

non-minified: http://laserey.es/media/javascripts/base.js


People "learning" by copying, coupled with large popularity, are what gave JavaScript, PHP and Perl such bad reputations. There are tutorials for most of the things newcomers might want to do in JavaScript. As such, I wouldn't place much value in people copying my work when deciding if minification is necessary.

I assume we're talking about individual per-site code here, since they can always download non-minified versions of commonly served frameworks easily somewhere else.


In fairness, I learned the same way, then learned to do it right. Back when AOL started providing Web access, one of the first things I noticed was the "view source" command. I learned how to make Web pages just by looking at existing ones and mauling them until they broke to see how the code worked. Later I got actual books and learned to do it properly.


This learning by copying are what made JavaScript, PHP, and Perl so popular.


Popularity is not the only success-factor to consider regarding programming languages. I'd contend that the ubiquity of javascript makes certain that it will retain (and grow) popularity for quite some time even without the easy "view source" option.

We're simply moving from one era into another; nothing wrong with progress!


I would say DHTML, mod_php and CGI instead.


This is an easy problem to solve.

Include paths to the original JS files (un-minified) at the top of the minified JS file as comments.


Some modern compressors such as YUI Compressor use real JS engine to parse your script and therefore can detect syntax error during minification, I can't see any reason why not using it.


I remember FSF's "free" JS campaign, and it basically comes down to something like this.


prettyprinter.de




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: