Improve Site Speed with YSlow

by jim on December 23rd, 2009

YSlow is a great Firefox add-on that is integrated with the Firebug extension, which is itself a great extension for web development.

First, download Firefox. Then visit the YSlow website to get Firebug and YSlow. You’ll have to restart but once you do, look for the little bug icon in the lower right.
YSlow and Firebug in Firefox

Once the Firebug panel comes up, find the YSlow tab (likely the right most one) and click it.

Running YSlow

I use the “Small Site or Blog” ruleset when looking at blogs but I recommend running it on all three to see how their rules differ for reach “type” of site. Then click on “Run Test.”

YSlow Results

From here, you probably will discover a laundry list of items you can optimize on your site. The results I show above are from Bargaineering and they’re an “A” because I spent a few hours implementing all the optimizations they recommended. When I first ran it, the overall results were a D or an F (I forgot, but at that point it doesn’t really matter, does it?).

If some of their recommendations don’t seem to make sense in the brief explanation they give, clicking on read more will send you to their Best Practices for Speeding Up Your Web Site website with more detailed information.

Low Hanging Fruit

If you’re looking to fix only a few things and want the most bang for your buck, I recommend jumping over to the components tab and looking at all of your images. You can try optimizing the size of your images using, click on the link to the right and a pop up will show you the size savings of smushing the images. This will only work on images hosted locally because you won’t be able to modify images you may be hotlinking (which is a bad practice anyway). If you want to save it, just click on “Click here to view or save the result image” and overwrite your existing image.

Another quick win? Tell your server to gzip content from your site. “Gzipping generally reduces the response size by about 70%. Approximately 90% of today’s Internet traffic travels through browsers that claim to support gzip.” That’s a pretty substantial savings for very little work.

If you’re using WordPress, I throw this at the top of my theme’s header.php :
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start();

As always, test after any change to ensure you didn’t frak something up.

RSS Subscribe Like this article? Get all the latest articles sent to your email for free every day. Just click "Subscribe" and enter your email. Your email will only be used for this daily subscription and you can unsubscribe anytime.

15 Responses to “Improve Site Speed with YSlow”

  1. Patrick Says:

    Jim, should there be something after this line:

    “If you’re using WordPress, I throw this at the top of my theme’s header.php :”

  2. Mike Says:

    I think there is a typo in the beginning – “<? php" shouldn't have a space.

    I couldn't get this to work on my site (Thesis theme/host = Media Temple). I put the code in the header script via Thesis options and then used hooks to put it before the html starts as well as before the header (I did all these options separately). The site works fine but no gzipping was happening.

    I found this article on MT's site which explains how to enable the mod_deflate function (which apparently replace mod_gzip). It's not hard but you need to use vi editor to complete it.

  3. Mike Says:

    Update – I tested my site with and it is compressing properly but Yslow is still indicating that my site is not compressed.

    So maybe just adding your code to my header did work. 🙂

  4. Mike Says:

    Ok, never mind. Turns out the yslow doesn’t recognize mod_deflate.

  5. Ben Says:

    is frak a real word?

  6. jim Says:

    Yeah, it’s from Battlestar Galactica. 🙂

  7. Kosmo @ The Casual Observer Says:

    There’s an errant space between the ? and php in the first line of the script. If you remove that, it will work much better 🙂

  8. jim Says:

    Yeah, I put that in there purposely so the code wouldn’t be executed by the server… but I figured out how to get it right without the intentional syntax error. 🙂

  9. » Site Speed May Soon Affect Search Rankings Says:

    […] site speed tools that you can use to make your site faster. The toolkit is more extensive than YSlow but the end goal is the same – identify the slow points in your site and help you improve […]

  10. » How to GZip CSS Files Says:

    […] line and check your work. If all looks OK, check to see that it’s gzipped. If you are using YSlow, just run YSlow on your site. One of the grading factors is “Compress components with […]

  11. Pinyo Says:

    Good stuff!

  12. TFB Says:

    Thank you for the writeup. You led me to some small improvements already. Too bad my host (Hostgator) does not enable mod_deflate or mod_gzip for shared hosting.

  13. jim Says:

    Man that stinks… is there anyway you can convince them to enable it?

  14. TFB Says:

    Hostgator has mod_deflate as a premium feature for VPS hosting. So I doubt they will give it away unless I upgrade and pay more. Is there any way to pre-compress the css files manually and serve them? The css files don’t change that often. Thanks.

  15. » Why I Dropped Homepage Google Adsense Says:

    […] the user experience because I want to make the site the best it can be. That’s why I try to make it faster using tips from YSlow and why I, about a year and a half ago, decided to remove Google Adsense from […]

Leave a Reply