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
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.
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