To Minify or Not To MinifyOct 30, 2009 In Development By Karsten Januszewski
Back when we were about to ship Oomph2, I found myself ranting about having to minify the oomph.js script.
Minifying was this annoying, non-automated step in the build process, and it caused me grief—just when we thought we were ready to ship and I’d minified what I thought was the final build, a bug would pop up. I’d have to start all over.
The 32KB Difference
It was during one of these rants that Joshua, who sits next to me and is often subject to my rants during development, noted that my minification was shrinking a 62KB script into a 30 KB script—a negligible difference. This led to a discussion about whether that 32KB really made any difference. I did the minification because it seemed like a best practice. I wanted to show that we “got it"—that yes, squeezing every bit of performance out of the download was the way to go.
But was it? And were 32KB’s worth all the trouble? Maybe not.
Minification is Anti View Source
Even if there exists somewhere a non-minified version of that same script, it’s likely that, right at that moment when you are browsing a page and think “Oh that’s cool; I wonder how they did that,” you won’t actually go off and find the unminified version of the script. And even if you did manage to find it, you’ll likely be stuck with a script removed from the context of the page in which you discovered the script in the first place.
In other words, minification is anti view source.
But It Does Make Sense
I’m not sure where I land on minification. I haven’t formulated a position quite yet.
I do know this: When I was minifying Oomph, I used a very cool, Microsoft internal-only minification tool. With the most recent release of the Microsoft AJAX toolkit, this tool has been made available to the world.
The Microsoft Ajax Minifier download includes the following components:
To read more about the minifier, check out Scott Guthrie’s excellent blog post, which talks about how the minifier works, and provides comparisons (based on compression rates) with other minifiers out there.
I’m curious about other folks’ thoughts on this topic: to minify or not to minify?