Reduce HTTP Requests


Feb
13
2008

For those who use the Yahoo YSlow plugin for Firebug, speeding up their websites is obviously an issue worth addressing.

There are several ways to increase the speed of page loads. This includes:

  • GZip/Deflate files server-side
  • Add expires headers
  • Minify JS files
  • Compress CSS files
  • CSS sprites for background images

There are several other ways to increase the speed of page loads including caching and reducing HTTP requests.

With this in mind, aciddrop.com has a nifty PHP script that performs multiple tasks. This includes minifying JS files, GZipping files, adding far future expires headers and decreasing HTTP requests.

This plugin will be useful for less tech-savvy users, or those who want a simple PHP-based solution that doesn’t involve delving into the server files or using htaccess files.

The PHP Speedy script is very easy to implement. Simply add the following code to the very top of your pages:

require_once('class.compressor.php'); //Include the class. The full path may be required
$compressor = new compressor('css,javascript,page');

Then add the following to the bottom of the page:

$compressor->finish();

To download the script click here. For more details and advanced features visit acidpro.com.

  • Digg
  • Sphinn
  • Propeller
  • StumbleUpon
  • Twitter
  • del.icio.us
  • Facebook
  • FriendFeed

Related Posts



4 Responses to “Reduce HTTP Requests”

  1.  

    I checked out Yslow on my website and I flunked the top five results right away. Dang!

    I found this article and that is terrific. I went over to read the comments and it seem the author hasn’t had a chance to really test it on WordPress so I was wondering how you were doing with this. Did you have to create a subdirectory like in the comments over there?

    I need to do this, especially for the gzip because for some strange reason my WordPress wont save the box I checked for gzip. It works on my sub-domains but not my main site. Weird. But anyways, I am very curious because it sounds like it would solve some issues but a little nervous at the moment about messing around with it.

  2.  

    I think it’s quite difficult to get a 100 percent rating. I wouldn’t worry to much as long as you notice an improvement in overall page loads.

    The one that gets most people is the “Use a CDN”. This is something global corporations are more likely to use to improve speeds.

    It’s not particularly relevant for the general user. However, you can bypass this feature by adding your own CDN to Firefox. Here is the FAQ on doing this: http://developer.yahoo.com/yslow/faq.html#faq_cdn

  3.  

    Have you tried out the PHP Speedy on this site? I am getting a little better but still flunking my YSlow scores. I need to figure out how to add the far future expires without screwing up everything else.

    In any case, all the info you have been providing here has been terrific so wanted to let you know thanks for the good articles.

  4.  

    Thanks Mark, I find the far future headers quite a difficult one.

    When you are pulling in third-party JavaScripts’ such as Google Analytics or social bookmarking scripts, they will not be included in your server-side far future header settings.

    The problem with this, is YSlow! shows this in the results, but really there isn’t much you can do about third-party hosted scripts.

    Thanks for the respect Mark! Much appreciated.

Leave a Reply