src="http://creatives.commindo-media.de/static/smashing-magazine-advertisement.gif" alt="Smashing-magazine-advertisement in Website Performance: What To Know and What You Can Do" border="0" />|
src="http://creatives.commindo-media.de/www/delivery/avw.php?zoneid=56" border="0" alt=" in Website Performance: What To Know and What You Can Do" />
src="http://creatives.commindo-media.de/www/delivery/avw.php?zoneid=63" border="0" alt=" in Website Performance: What To Know and What You Can Do" />
src="http://creatives.commindo-media.de/www/delivery/avw.php?zoneid=64" border="0" alt=" in Website Performance: What To Know and What You Can Do" />
src="http://imp.constantcontact.com/imp/cmp.jsp?impcc=IMP_DIMPBPRSMASHRSS&o=http://img.constantcontact.com/lp/images/standard/spacer.gif" alt="Spacer in Website Performance: What To Know and What You Can Do" border="0" width="1" height="1" />
Website performance is a hugely important topic, so much so that the big companies of the Web are obsessed with it. For the Googles, Yahoos, Amazons and eBays, slow websites mean fewer users and less happy users and thus lost revenue and reputation.
In your case, annoying a few users wouldn’t be much of a problem, but if millions of people are using your product, you’d better be snappy in delivering it. For years, Hollywood movies showed us how fast the Internet was: time to make that a reality.
Even if you don’t have millions of users (yet), consider one very important thing: people are consuming the Web nowadays less with fat connections and massive computers and more with mobile phones over slow wireless and 3G connections, but they still expect the same performance. Waiting for a slow website to load on a mobile phone is doubly annoying because the user is usually already in a hurry and is paying by the byte or second. It’s 1997 all over again.
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/01/optimization.gif" width="489" height="330" alt="Optimization in Website Performance: What To Know and What You Can Do" />
Performance is an expert’s game… to an extent. You can do innumerable things to make a website perform well, and much of it requires in-depth knowledge and boring testing and researceh. I am sure a potential market exists for website performance optimization, much like there is one now for search engine optimization. Interestingly, Google recently announced that
href="http://www.downloadsquad.com/2009/11/14/google-to-use-page-load-speed-as-a-search-result-ranking-factor/">it will factor performance into its search rankings, so this is already happening. That said, you can do a lot of things without having to pay someone to point out the obvious.
Know Your Performance Blockers
So here are the things that slow down your page the most.
External Resources (Images, Scripts, Style Sheets)
Every time you load something from another server, the following happens:
- The browser opens up the Internet’s address book and looks up the number associated with the name of the server that’s holding the things you want (i.e. its
- It then negotiates a delivery.
- It receives the delivery (waiting for all the bytes to come in).
- It tries to understand what was sent through and displays it.
The first thing to know about scripts that you include in a document is that they are not HTML or CSS; the browser has to call in an expert to do something with them. Here is what happens:
- Whenever the browser encounters a
- The script engine then looks at the content in the script block (which may have been delivered earlier), sighs, complains about the poor code, scratches its head and then does what the script tells it to do.
- Once the script engine is done, it reports back to the browser, which puts down its coffee, says good-bye to the script engine and looks at the rest of the document (which might have been changed, because the script may have altered the HTML).
Here is where things get interesting. Optimizing images has always been the bane of every visual designer. We build our beautiful images in Illustrator, Photoshop or Fireworks and then have to save them as JPG, GIF or PNG, which changes the colors and deteriorates the quality; and if we use PNG, then IE6 arrives as the party-pooper, not letting us take advantage of PNG’s cool features.
Finding the right balance between visual loss and file size can be daunting, but be grateful for the Web preview tool, because we didn’t always have it. I recall using Photoshop 4 and then Photoshop with the Ulead SmartSaver, for example.
The interesting thing about images, though, is that after you have optimized them you can still save many more bytes by stripping unnecessary data from the files and running the files through tools that further compress the images but are non-lossy. The bad news is that many of them are out there, and you’ll need different ones for different image formats. The good news is that tools exist that do all that work for you, and we will come back to this later. For more advanced optimizaition techniques feel free to take a closer look at the Smashing Magazine’s articles
href="http://www.smashingmagazine.com/2009/07/01/clever-jpeg-optimization-techniques/">Clever JPEG Optimization Techniques,
href="http://www.smashingmagazine.com/2009/07/25/png-optimization-guide-more-clever-techniques/">PNG Optimization Guide and
href="http://www.smashingmagazine.com/2009/07/15/clever-png-optimization-techniques/">Clever PNG Optimization Techniques.
Simple Tools You Can Use Now To Improve Performance
All of those companies that obsess about page performance offer tools that allow you to check your own website automatically and make it easy to work around problems.
Test Your Performance
The first thing to do is find out how your website can be optimized. Here are three great tools (among others that crop up all the time) to use and combine.
href="http://developer.yahoo.com/yslow/">YSlow is a Firebug add-on from Yahoo that allows you to automatically check your website for performance issues. The results are ranked like American school grades, with A being the best and F being the worst. The grades are cross-linked to
href="http://developer.yahoo.com/performance/">best practice documentation on the Yahoo performance pages. You can test several settings: “classic YSlow,” which is targeted to Yahoo-sized websites, “YSlow 2″ and “small site or blog.” Results are listed clearly and let you click through to learn.
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/01/image1-new.jpg" width="550" height="600" alt="Image1-new in Website Performance: What To Know and What You Can Do" />
In the components view, YSlow lists all of the issues it has found on your website and how serious they are:
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/01/image2new.jpg" width="550" height="600" alt="Image2new in Website Performance: What To Know and What You Can Do" />
The statistics view in YSlow gives you all information in pie charts:
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/01/image3.gif" width="474" height="307" alt="Image3 in Website Performance: What To Know and What You Can Do" />
The tools section in YSlow offers a lot of goodies:
- All JS
- All JS Beautified
- All JS Minified
- All CSS
/> Show all CSS code in a document
- All Smush.it
/> Automatically compresses all of your images (more on this later).
- Printable View
/> Creates a printable document of all of YSlow’s results (great for showing to a client after you’ve optimized the page!)
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/01/image4.gif" width="500" height="316" alt="Image4 in Website Performance: What To Know and What You Can Do" />
Google’s Page Speed
href="http://code.google.com/speed/page-speed/">Page Speed by Google is also an add-on for Firebug. Its main difference is that it does a lot of the optimization for you and provides the modified code and images immediately.
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/12/4198657574_5865ccbda5.jpg" alt="4198657574 5865ccbda5 in Website Performance: What To Know and What You Can Do" />
Page Speed’s other extra is that it monitors the overall activity of your page, allowing you to see when a document loads other resources after it has been loaded and to see what happens when a user rolls over elements or opens tabs and menus that load content via AJAX.
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/12/4198689498_2e2acd4ccf.jpg" alt="4198689498 2e2acd4ccf in Website Performance: What To Know and What You Can Do" />
Be careful with this feature, though: it hammers your browser quite hard.
Rather late to the game,
href="http://www.webpagetest.org/">AOL’s WebPageTest is an application with some very neat features. (It is also available as a desktop application, in case you want to check Intranets or websites that require authentication.)
WebPageTest allows you to run tests using either IE8 or IE7 from a server in the US or the UK, and it allows you to set all kinds of parameters, such as speed and what to check for:
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/12/4198701698_900086ced1.jpg" alt="4198701698 900086ced1 in Website Performance: What To Know and What You Can Do" />
Once you have defined your parameters and the testing is completed, you will get in-depth advice on what you can do to optimize. You’ll get:
- A summary,
- Detailed results,
- A performance review,
- An optimization report,
- The content breakdown,
- The domain breakdown,
- A screenshot.
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/12/4198726620_9a32df8ff4.jpg" alt="4198726620 9a32df8ff4 in Website Performance: What To Know and What You Can Do" />
One very cool feature of WebPageTest is the visual recording you get of how long it takes for page elements to show up on screen for users. The following screenshot compares the results of this blog, Ajaxian and Nettuts+:
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/12/4198697096_7eff3706bf.jpg" alt="4198697096 7eff3706bf in Website Performance: What To Know and What You Can Do" />
You can even create a video of the rendering, which is another very cool thing to show clients.
Once you get the test results, it is time to fix any problems.
Use Image Sprites
href="http://www.alistapart.com/articles/sprites/">Image Sprites were first discussed in an article published by Dave Shea and based on the work of
href="http://wellstyled.com/css-nopreload-rollovers.html">Petr Stanicek. They have been covered
href="http://www.smashingmagazine.com/2009/04/27/the-mystery-of-css-sprites-techniques-tools-and-tutorials/">extensively here before, but understanding their full benefit is important before you start using them:
- All of your images will be available as soon as the main image has loaded (no flickering on roll-overs or other annoyances).
- One HTTP request is made, instead of dozens (or hundreds, in some cases).
- Images have a much higher chance of staying cached on the user’s machine because they are contained in a single file.
Shea’s article points out a lot of cool resources for creating CSS Sprites but misses one that was released not long ago.
href="http://spriteme.org/">Sprite Me was produced by Google (under the supervision of Steve Souders) and allows you to create Sprites automatically from any website, even via a bookmarklet. It analyzes the images on a page and offers you various options before generating the Sprite and CSS for you.
href="http://www.youtube.com/watch?v=pNfRL-TwzZY#t=27m21s">a video of Steve showing Sprite Me in action:
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/12/4196848773_9d6e3b8da5.jpg" alt="4196848773 9d6e3b8da5 in Website Performance: What To Know and What You Can Do" />
Optimize Your Images
You know now that Page Speed can automatically optimize your images. Another way to do this is with Yahoo’s Smush It, which is a set of image optimization tools that analyze your images, create the smallest possible versions and sends you a ZIP file of them all.
You can use
href="http://www.smushit.com/ysmush.it/">Smush.it directly in the browser or automatically from YSlow. The website tells you how many bytes you can save by optimizing your images. This is yet another cool thing to show potential clients when pitching for a job.
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/12/4197963651_f99567a8f0.jpg" alt="4197963651 F99567a8f0 in Website Performance: What To Know and What You Can Do" />
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/12/4197968099_720bc44915.jpg" alt="4197968099 720bc44915 in Website Performance: What To Know and What You Can Do" />
Collate Scripts and Load Scripts on Demand
As noted, try not to spread your
<script> nodes all over the document, because the browser stops whenever it encounters one. Instead, insert them as far down in the document as possible.
You could even collate your scripts automatically in one single include using back-end scripts. Edward Eliot
href="http://www.unwrongest.com/projects/lazy/">lazy load jQuery plug-ins.
src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/12/4196935915_39584ab3e9.jpg" alt="4196935915 39584ab3e9 in Website Performance: What To Know and What You Can Do" />
Notice that a tab tells you what the overall size of the library will be.
Use Network Distributed Hosting
If you use a library or CSS provided by a library, make sure to use the hosted versions of the files. In the case of YUI, this is done for you if you use the configurator. And you can pick from Yahoo or Google’s network.
For other libraries, there is a
href="http://code.google.com/apis/ajaxlibs/">Google code repository of AJAX libraries. This is useful for a few reasons:
- There is a high probability that these servers are faster than yours.
- Visitors who have visited other websites that use the same includes will already have them on their computers and won’t need to load them again.
- You save on bandwidth and can easily upgrade the library by changing the version number of the include.
While you probably wouldn’t be able to afford distributed hosting for your own files,
href="http://www.coralcdn.org/">Coral makes an interesting offer to distribute your data onto a network of servers for an affordable $50 a month.
Watch Some Videos
If you want to see how some of this work, check out the following videos, especially Nicole Sullivan’s, which shows some very cool CSS tricks:
href="http://developer.yahoo.net/blogs/theater/archives/2009/04/yslow_update_screencast.html">Using YSLow 2.0
href="http://www.youtube.com/watch?v=a-9pCfyYPdQ">Using Google Page Speed
href="http://yuiblog.com/blog/2008/12/23/video-sullivan/">Nicole Sullivan tells you not to blame the rounded corners but to design for fast websites
href="http://www.youtube.com/watch?v=pNfRL-TwzZY#t=27m21s">Steve Souders showing Sprite Me
href="http://www.yuiblog.com/blog/2008/12/23/video-crockford-performance/">Douglas Crockford on AJAX performance.
Follow The Leaders
To learn more about website performance, here are some resources and people to follow. (Be warned: some of the content is technically tough.)
href="http://developer.yahoo.com/performance/">The Yahoo Developer Network Performance Section
/> Home of YSLow and probably the first official performance research website.
/> A collation of all performance blogs and posts in one RSS feed.
href="http://www.stevesouders.com/">Steve Souders (
/> Ex-maintainer of the performance section of Yahoo, now at Google. Author of the biggest performance books. And organizer of the Velocity conference.
href="http://stubbornella.org/content/">Nicole Sullivan (
/> Ex-team member of the performance group at Yahoo and co-creator of Smush.it. Also CSS performance goddess with great tips for designers. Currently working on making Facebook perform better.
href="http://phpied.com/">Stoyan Stefanov (
/> Coder of Smush.it and member of the performance team at Yahoo. Created his own
href="http://www.phpied.com/performance-advent-calendar-2009/">advent calendar of performance tips this year, and runs Performance Planet, as mentioned above.
href="http://website-performance.org/">Ed Eliot and Stuart Colville
/> Builders of the
href="http://spritegen.website-performance.org/">CSS Sprite Generator.
href="http://www.jakearchibald.com/">Jake Archibald (
/> Lead developer of the BBC’s Glow library. Delivered a
href="http://www.jakearchibald.com/jsperformance/">great talk on performance at this year’s Full Frontal conference.
href="http://bluesmoon.info/">Phillip Tellis (
/> Performance junkie at Yahoo.
- And me, their fanboy and person asking for features:
href="http://wait-till-i.com/">Chris Heilmann (
© Christian Heilmann for
href="http://www.smashingmagazine.com">Smashing Magazine, 2010. |
href="http://www.smashingmagazine.com/2010/01/06/page-performance-what-to-know-and-what-you-can-do/#comments">90 comments |
title="Bookmark in del.icio.us" href="http://del.icio.us/post?url=http://www.smashingmagazine.com/2010/01/06/page-performance-what-to-know-and-what-you-can-do/&title=Website%20Performance:%20What%20To%20Know%20and%20What%20You%20Can%20Do">Add to del.icio.us |
title="Bookmark in Digg" href="http://digg.com/submit?phase=2&url=http://www.smashingmagazine.com/2010/01/06/page-performance-what-to-know-and-what-you-can-do/">Digg this |
title="Stumble on StumbleUpon" href="http://www.stumbleupon.com/submit?url=http://www.smashingmagazine.com/2010/01/06/page-performance-what-to-know-and-what-you-can-do/">Stumble on StumbleUpon! |
title="Tweet us!" href="http://twitter.com/home?status=@tweetmeme%20@smashingmag%20Reading%20'Website%20Performance:%20What%20To%20Know%20and%20What%20You%20Can%20Do'%20http://www.smashingmagazine.com/2010/01/06/page-performance-what-to-know-and-what-you-can-do/">Tweet it! |
title="Bookmark in Reddit" href="http://reddit.com/submit?url=http://www.smashingmagazine.com/2010/01/06/page-performance-what-to-know-and-what-you-can-do/">Submit to Reddit |
href="http://forum.smashingmagazine.com/">Forum Smashing Magazine