Welcome to Website Magazine LOGIN | SIGN UP
Advertise at Website Magazine
posted on Monday, September 10, 2007 1:00 PM by PetePrestipino

Let's Look at Minify

View the source code on your webpage and you may find that there are multiple CSS or JavaScript files. While CSS simplifies design and JavaScript adds essential functionality, the browser must request each referenced file individually (and wait for them to finish), which often causes pages to load slower than your users are willing to wait. The issue of latency is an important one for designers and developers and should be addressed if you find that users are not getting the whole "experience" from your site.

Found within Google Code: "Minify attempts to fix this problem by combining multiple CSS or JavaScript files into one download. By default, it also removes comments and unnecessary whitespace to decrease the amount of data that must be sent to the browser. Most importantly, it does all of this on the fly and requires only a few simple changes to your existing web pages."

Sounds pretty interesting. Let's take a closer look. Say for example that you have two CSS files and two JavaScript files. Your HTML would look something like this:

CLICK TO ENLARGE:

When you implement Minify on your server (through mod_rewrite on an Apache server, or through a PHP script), it would look something like this:

CLICK TO ENLARGE:

As you can see, just one request is necessary to pull up multiple external CSS and JavaScript files.

Comments