Slice loading time in half with fewer HTTP requests
Reducing the number of HTTP requests is the key to faster pages. A simple way of doing this is by combining javascripts and stylesheets into single files using Rakaz’s combine script.
According to Yahoos article “Best Practices for Speeding Up Your Web Site” about 80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, stylesheets, scripts, Flash, etc. Reducing the number of components in turn reduces the number of HTTP requests required to render the page.
One way of reducing the number of HTTP requests while still support rich page designs is to use a server side script that combines all your javascripts and styles into single files. A php script that does exactly that is Rakaz’s combine.php.
When the script is configured and ready to use all you need to change are the urls to your scripts and styles. You will go from doing, in this case, four requests to only one.
<script src="jquery-1.3.2.js" type="text/javascript"></script> <script src="jquery.valid8-1.1.1.js" type="text/javascript"></script> <script src="jquery.defaultvalue-1.0.js" type="text/javascript"></script> <script src="global.js" type="text/javascript"></script>
<script src="jquery-1.3.2.js,jquery.valid8-1.1.1.js,jquery.defaultvalue-1.0.js,global.js" type="text/javascript">
Rakaz’s script will also compress and cache your combined files to reduce loading times even more. You can find a complete installation guide and more information about the script over at rakaz.nl
Real world example
I just uploaded and configured combine.php for http://chat.unwrongest.com. Before the script was added you needed to download 10 javascript files that weighed 232 kb in total. On average this took about 3 seconds to download. After installing the combine.php script you now need to download only a single file of 68 kb which only takes around 1 second to download. The total loading time of chat.unwrongest.com is now, for me, around 2 seconds instead of just above 4 seconds.
Projects
- Accordion (jQuery)
- Airport (jQuery)
- Defaultvalue (jQuery)
- Elastic (jQuery)
- Highlight (jQuery)
- Keycan
- Lazy (jQuery)
- Limit (jQuery)
- Password Strength (jQuery)
- Show Password (jQuery)
- Tabify (jQuery)
- Valid8 (jQuery)
Latest posts
- July 8th, 2009 Why are we typing passwords twice?
- July 5th, 2009 Don’t stop password masking; let the user decide
- June 1st, 2009 You can’t validate email addresses with regular expressions
- May 20th, 2009 Konami Code: Why so verbose, when you can make it in 140 characters?
- May 18th, 2009 Let your users know if Firebug slows down your web page.