At least it does for web pages.
“Try holding your breath for as long as it takes your home page to load. If you are now dead, it took too long.”
- Art and the Zen of web sites
A decade ago, in the age of dial-up connections, page weight was everything. Images were compressed to within an inch of their lives and Netscape (R.I.P.) even had a special attribute for a lower resolution image to use as a placeholder while the proper image loaded. Then along came broadband and web developers got lazy.
- Prototype: 126KB
- gzipped version: 28KB
- Minified: 71KB
- Minified and gzipped: 21KB
Minifying before this compression gives us a saving of just under 7KB. This may not sound like a lot but multiply this up and it results in a bandwidth saving of a gigabyte per day if the file is served at a rate of a little under 2 requests per second, which is not unrealistic for a popular site. Also remember that this is just for one file. Automating this extra minification step is easy enough if you’re developing on OS X or a flavour of UNIX. You can also add some functionality to your webserver if you want to really show off but I’ve come up with a way to reduce the steps needed to a single click with Windows XP:
- Download the Yahoo compressor and unzip it. It’s Java, so you’ll need to make sure that you’ve got the runtime somewhere on your path. I placed mine in the
C:Program Filesdirectory but if you decide that you want to put it elsewhere you’ll need to edit the batch file (see next step).
- Download my batch file and save it to a directory that is on your path.
C:Windowsfor example. You’ll need to edit this file to reflect the location of the Yahoo compressor or if you upgrade to a newer version at sometime in the future.
- Download and run my registry keys to install right click handlers to your context menu.
- Right click on a
.jsfile and choose “YUI Compress”. A minified version will appear right alongside the original file with the extension
.min.jsdepending on the original file.