georgi

Building fast web sites with Yahoo!’s Exceptional Performance Team

Yahoo!’s Developer Theater has always been a priceless resource for web designers and developers. But what I have found the most useful video for me was Steve Souders’ High performance websites presentation. For those of you who don’t have the time to watch the whole video – here is a short summary.

Like many things in our Universe, web performance obeys Pareto’s 80-20 principle – 20% of the elements of a website cause 80% of the effects on the performance. And if we try to slightly reduce the time spent on loading those 20% of the elements, we can get much more than 20% increase in speed.

Are servers the root of all evil?

And as most of you probably already guessed – most of the server-side elements are not within those 20%. If you slightly improve ( or think you have ) your PHP algorithms or your SQL queries, you will probably gain benefits which are close to the statistical error. ( Here we are not talking about drastic changes or bug fixes in faulty software which shouldn’t have been there in the first place ).

Speed up the browser

What turns out to have the greatest impact on loading times and user experiences are the elements which load into the browser. And writing speed enhancements for the browser is out of our scope right now – we can just try to adapt our web pages, so that it is easier for it to parse and display. Here are my top 5 rules which have given me fantastic results.

Number of HTTP requests

If we are to believe Yahoo!, 80% of the time spent loading a web page is taken by downloading the entities of that page – mainly css, javascripts and images. The problem here is that we have too much unimportant (for the users) data sent back and forth, also known as headers. Even the smallest image has its request and response headers traveling with it across the Net. So, my advice is – combine your javascript and css files and use css sprites’ images. These are image maps which hold all of your images in one file and thus only this single file is sent over with its headers. Read more on css sprites here.

Expires header

This technique is very simple, yet very powerful and rarely used. Expires headers tell the browser that the entity it has requested *will not be changed* until some date. In practice, this means that the browser will not download that entity, if it already has it in its cache – 0 bytes transfered. Be careful, though, if you need to change something on the fly ( especially when still developing a site ), you will have to change the name of that file, so that the browser doesn’t think it already has it in the cache. This can easily be avoided using a simple versioning technique ( a link to some-file.js can look like some-file.js?version=1.0 and can later be changed to some-file.js?version=1.1 which will instantly make the browser fetch the file again as the url has changed ).

So, here – simply set a far-future Expires header on static content.

GZip

Also very useful, especially on large text files (like css and javascript files). This will effectively compress your content on the server, then send it to the browser which will uncompress it and use it. But be careful – don’t use this on images as it can be counter-productive. All A grade browsers support gzipped responses, so no worries about compatibility here.

Javascript and CSS

You should already know this but just in case – compress and minify your javascript and css files; put css at the top and javascript at the bottom. Simple, heh?

Flush it!

Well, the only server-side technique in my top 5 – flush your output buffer early ( just after the <head> tag ). This is very helpful on sites rich in html and text content because it will send the <head> of the html document fast enough so that the browser may start downloading the respective css files ( which you have put in the head, as described in the previous rule ) and underlying css images before the rest of the document has been transfered. Otherwise, you may end up in a situation where the whole HTML document needs to be received before css and the images can start being fetched.

This is just a sneak overview of the techniques – for a thorough list and technical help, please visit yahoo’s site

Tags: , , , , , , , , , , ,

2 Responses to “Building fast web sites with Yahoo!’s Exceptional Performance Team”

  1. Test Says:

    some tutorial comment!…

  2. Ovalpixels Blog about Web-Building » Blog Archive » Making fancy websites without Flash: Introduction Says:

    […] just for the Flash to load and then start-up, this makes me a bit nervous. And as I have previously stated on this blog, loading time is crucial for web visitors. Each second can be […]

Leave a Reply