Speed up page load time by nearly 50%
Of all the factors that can affect the load time of a web page, fetching handfuls of stylesheets and javascript files is certainly high on the list. Many would approach a solution to this at the server level, however Niels Leenheer has an interesting solution that takes place at the script level, instead.
Leenheer describes his solution in “Make Your Pages Load Faster by Combining and Compressing Javascript and CSS Files“. The step-by-step goes like this:
- Organize CSS and JavaScript files into directories dedicated to those types of files.
- Mod_rewrite the URLs of those directories to a PHP script, passing along the paths to the original css or javascript files in the query string.
- Use the PHP script to concatenate the stylesheets/scripts, gzip the output and send it to the client.
I have not tested this scheme, but Leenheer reports that a test page’s load time was drastically reduced from 1095 ms to 400 ms.
November 12th, 2008 at 6:02 pm
dl27cir1fq2g5ijt