
Committed to keeping up with the latest in Firefox and Firebug development, we’re happy to announce that a new version increment of YSlow was released, mainly aiming at addressing compatibility. What’s in this release?
Looking at the diversity of Firefox/Firebug versions, these are the current available branches for Firefox and Firebug.
Firefox has two active branches:
Firebug has 3 active branches:
Firebug 1 doesn’t work with Firefox 3, so there are a total of 5 combinations and the YSlow 0.9.5b1 has been successfully tested on all of them:
| Firebug 1 | Firebug 1.1 | Firebug 1.2 | |
| Firefox 2 | Yes | Yes | Yes |
| Firefox 3 | N/A | Yes | Yes |
You can download the tool here, report bugs here, read the performance rules, and participate in the performance mailing list discussions. Also make sure you keep an eye on our performance-related postings on YDN and YUI Blog.
Enjoy,
Yahoo! Exceptional Performance
Posted by tenni at 10:37 AM | Comments (2) | TrackBack
Initially 13, then 14, and now 34 performance best practices have been released. As promised, we've updated our pages to include details on each of these new rules. The rules will gradually find their way into YSlow, at least those that are testable. Huge thanks goes out to all those at Yahoo! who helped identify, validate and test the new best practices, and especially to our very own Stoyan Stefanov who put it all together. Stoyan Stefanov is part of the Exceptional Performance team and also the lead developer for YSlow.
We hope you'll find some interesting ideas to help you accelerate the user experience on your pages today. Any comments and feedback appreciated. Let's make the web a better place!
Tenni Theurer
Yahoo! Exceptional Performance
Posted by tenni at 4:44 PM | Comments (1) | TrackBack
Stoyan Stefanov made an appearance last week at the PHP Quebec Conference in Montreal. His session debuts Yahoo!’s latest research results and performance breakthroughs. He covers the existing 14 rules, plus 20 new rules for faster web pages. We’ve categorized the optimizations into: server, content, cookie, JavaScript, CSS, images, and mobile.
After YSlow "A"?
If your page isn't getting an "A" in YSlow, I recommend that you tackle those recommendations first. However, if you're getting an "A" and looking for more ways to optimize your web pages, here are 20 new recommendations to accelerate the end-user's experience. Stay tuned, you'll be hearing more about YSlow and these rules at Yahoo! Developer Network and Yahoo! User Interface Blog.
| 1. Flush the buffer early | [server] |
| 2. Use GET for AJAX requests | [server] |
| 3. Post-load components | [content] |
| 4. Preload components | [content] |
| 5. Reduce the number of DOM elements | [content] |
| 6. Split components across domains | [content] |
| 7. Minimize the number of iframes | [content] |
| 8. No 404s | [content] |
| 9. Reduce cookie size | [cookie] |
| 10. Use cookie-free domains for components | [cookie] |
| 11. Minimize DOM access | [javascript] |
| 12. Develop smart event handlers | [javascript] |
| 13. Choose <link> over @import | [css] |
| 14. Avoid filters | [css] |
| 15. Optimize images | [images] |
| 16. Optimize CSS sprites | [images] |
| 17. Don't scale images in HTML | [images] |
| 18. Make favicon.ico small and cacheable | [images] |
| 19. Keep components under 25K | [mobile] |
| 20. Pack components into a multipart document | [mobile] |
Many thanks to all the developers at Yahoo! that have directly or indirectly contributed to this list - you know who you are (see credits at the end of Stoyan's presentation). We share our findings so that others can join us in accelerating the user experience on the web.
Tenni Theurer
Yahoo! Exceptional Performance
Posted by tenni at 4:02 PM | Comments (17) | TrackBack
YSlow, the performance lint tool created by the Yahoo! Exceptional Performance team was updated to version 0.9.3. today. This minor version increment contains:
,
about:config to set the option extensions.firebug.yslow.excludeBeaconsFromLint to false
In the spirit of openness and our commitment to a faster experience on the web, we hope you join us in accelerating the user experience.
You can download the tool here, report bugs here, read the performance rules, and participate in the performance mailing list discussions. Also make sure you keep an eye on our performance-related postings on YDN and YUI Blog.
Posted by tenni at 5:40 PM | Comments (20)
Performance is important to users. It influences click through rates, loyalty, and engagement. Users want fast websites that they can view from anywhere, including phones, wireless connections, laptops, and home computers. Users also want a graphically rich user experience with all the bells and whistles. Multimedia blends of video, images, feeds, and other components can be very slow indeed. Here at Yahoo! we spend a lot of time analyzing and improving the performance of our own sites. In honor of Super Tuesday, we thought it would be fun to take a poke at the Presidential Candidates web sites and share with you what we found.
How did they do? Overall, atrociously, all the candidates failed the YSlow exam except Mike Gravel who earned a "D". Page weight was a problem for Barack Obama, whose site weighed in at almost 700Kb. It was even worse for Mitt Romney, whose site weighed a whopping 1,531Kb. I hope he doesn't have supporters trying to make contributions on dialup modems!
Democrats got better grades in almost all performance subjects tested, in particular response times and page weight. They improved user experience for returning visitors by setting an Expires headers and improving the full cache user experience. This helped propel them to a performance GPA of "C" despite their failing YSlow grade. Republicans never managed to overcome the deficit and finished the semester with an "F".

Figure 1: Democrats versus Republicans Performance Report Card
Performance is one component in a balance of competing goals. These sites are trying to solicit support, donations, and volunteers. They need to provide a rich user experience that keeps people coming back, and engages them with the candidates' progress. Ultimately, they want to do this in a way that is fast, and accessible to as many voters as possible; including those on mobile phones, dialup modems, or low broadband.
Mike Gravel and Hillary Clinton's websites had the two best response times tested. Barack Obama's website came in fourth, after the leading Republican. Response time is all about getting the biggest user-experience bang for your buck. One reason Obama's site might be slower, is the amount of below-the-fold content. Many voters may not see this extra content, we human beings don't seem to like to scroll, but it still impacts performance.
Clinton, Obama, and Huckabee have graphically rich sites, and yet they are among the fastest. Do these sites succeed in engaging voters, or do they prefer the more serious, austere look of Gravel's site? The idea that a candidates website has a serious impact on his or her chances of being elected is relatively new. The rules and strategies are being invented now; we're living history.
Figure 2: Below the fold content might not be visible to voters, but it does affect response times
Figure 3: Democrats Response Time Report Card.
This graph shows all of the candidates' grades plotted together. Reaching the outside band means the candidate got an A, for instance Obama and Gravel received As in Image Optimization, while Clinton squeaked into a high-B. The closer the candidate got to reaching the edge of the ocatgon, the better their grade. In fact each band is equivalent to one letter grade. From roughly the halfway point to the very center are variations on a failing grade.
Clinton and Gravel provided two of the best performance-based user experiences recorded. However, Clinton had a large number of HTTP requests, which can slow down a site significantly. She counteracted that by setting an Expires headers so that returning voters would not have to pay the same performance penalty. Clinton also split static content across more than one domain to enable parallel downloads.
Examining Republicans performance offers a clear opportunity to witness the connection between response time and page weight. To deliver a fast site, hard choices have to be made about which features to include, and which to abandon.
Mike Huckabee's website combined low page weight and fewer http requests to achieve the best response time among Republicans and the third fastest response time overall. He could however trim 20Kb of fat from images with no loss of quality. We tested using lossless compression algorithms to determine how much extra baggage the candidates' pages were carrying. Romney was the real surprise in this category. The extra fat in his home page weighed more than Mike Huckabees entire page!
Image Optimization is the kind of low hanging fruit that makes your site faster with absolutely no loss for the user. The tool we built to test image formats and compression algorithms determined that John McCain was the master of image optimization; we were only able to remove 1Kb from his images.
Mitt Romneys site takes almost eight seconds to load even on a broadband connection. He got so many "F"s, our radar chart looks like Pollock on a bad day.
Figure 4: Republicans Report Card
Every one of these sites had outlying data points, that is, random response times of as much as 19 seconds. Romney even had a data point at 1.825 seconds, despite his more typical 5-10 second load times. These bad user experiences are real, and while most users just press reload and forget about it, it is important that we correct what we can, before they get frustrated and simply don't come back.
Comparing worst-case scenarios, medians, averages, YSlow scores, empty or primed cache experiences, and other measurements can help you get a fuller picture of your user experience. Rather than looking for one magic number, performance requires us to unravel a nuanced puzzle. Try to understand what your users see, and how you can make it better for them, whether they are voters, customers, or people coming to read your blog.
For those of you who like numbers, here's the data:
| Hillary Clinton | Barack Obama | Mike Gravel | Mike Huckabee | John McCain | Ron Paul | Mitt Romney | |
| YSlow | 59 | 52 | 66 | 50 | 42 | 36 | 33 |
| Page Weight (K) | 300 | 691 | 195 | 185 | 568 | 483 | 1531 |
| Response Time (S) | 2.6077 | 3.4810 | 2.3733 | 3.1148 | 6.5309 | 4.2125 | 7.5352 |
| HTTP Requests | 96 | 94 | 32 | 56 | 107 | 83 | 77 |
| Cookie Weight | 214 | 333 | 281 | 217 | 299 | 203 | 130 |
| Primed Cache - Page Weight (Kb) | 33 | 242 | 8 | 46 | 237 | 173 | 448 |
| Primed Cache - HTTP Requests | 4 | 93 | 4 | 56 | 107 | 76 | 77 |
| Wasted Image Weight (Kb) | 29 | 6 | 20 | 20 | 1 | 49 | 205 |
All measurements were taken using a MacBook Pro with Firefox, Firebug, and YSlow over a wireless connection. Page weights, cookie weights, and HTTP requests were determined via the YSlow Stats panel.
Should you choose the next president based on their YSlow score? Probably not, but, it is one of many interesting ways of evaluating how technically savvy they are in an increasingly technical world. Now don't get me wrong, I know the candidates didn't write their own HTML or optimize their own images, but they did choose the person who would do this work for them. That's what makes this game interesting; they have to choose the right people for the right jobs every day. Happy voting!
Nicole Sullivan, Technical Evangelist
Yahoo!'s Exceptional Performance
Posted by tenni at 9:09 PM | Comments (6)
In July 2007 I took over the reins from Steve Souders (my former boss, performance co-hort, and someone I greatly respect) as manager of Yahoo!’s Exceptional Performance team. I was humbled and excited about the opportunity to lead Yahoo!’s now worldwide effort on accelerating the user experience and making our products faster, better, and more efficient.
Improvements in web site performance are similar to improvements in energy or fuel efficiency. We make good progress yet we continue to consume more, which reverse the results of our improvements. The net effect is that optimizing performance is an on-going battle. To ring in the New Year, the Exceptional Performance team would like to share our 7 Habits for Exceptional Performance:
1. LOFNO – Look out for number one, that is, your users. Be an advocate for your users. You do control the user experience, so don’t settle for excuses and don’t make excuses. A lot of people shift the blame towards things they don’t control. The truth is that even if it’s slow ads or the framework that’s slowing down your site, chances are there are still things you can do personally to optimize performance for your users. Has every image been optimized? Have you evaluated whether users really use that feature you pushed so hard for? Did you run YSlow? Have you set the right tone and leadership so that others know performance is a top priority for your product? Focus on what you can do, not what you can’t do. Leave no stone unturned.
2. Harvest the low hanging fruit – Find the optimizations that give you the biggest bang for your buck. If your web site has many pages, prioritize the pages. Look first at pages with higher traffic since those are the ones your users visit most. Identify strategic pages, ones that are important for the business. Create a list of performance optimizations and then prioritize that list starting with what will improve performance most. Then prioritize the same list again based on how much effort is required. Remember that removing just one image can often improve the user’s perceived response time by as much as an entire rewrite of the backend. Implement the Rules for High Performance Web Sites (aka YSlow Rules). These rules were identified at Yahoo! as the low hanging fruit for making web sites faster without compromising design or features.
3. Balance features with speed – Exceptional performance is a cross-team discipline. Our performance golden rule tells us that 80-90% of the time a user waits for a page to load is spent on the front-end. This makes the decision about what goes into the product (design, features, etc.) a major chunk of the time a user spends waiting for the components (images, JavaScript, CSS, etc.) to come down the wire. Think Yin and Yang, a constant flux of alternating forces. Designers add visual appealing elements. Product managers add functionally rich features. Engineers add flexible frameworks. All this equates to more time a user waits for your page to load. Remove images, eliminate features, compress components – all that equates to less time a user waits. Faster response time reduces site abandonment and increases usability. Less abandonment and better usability increases page views. And hey, you’ll also have a happier, less frustrated user.
4. Start early and make performance part of the process – Don’t wait until right before your product is about to be launched to discover that your product performs badly. By then, it’ll be too late. Incorporate performance into the product roadmap at design time and requirements gathering. Make performance part of the process early in the development cycle. Run performance tests at every major milestone. Every feature has a performance cost associated with it. Develop a test methodology and measure that cost. If your website requires a login, profile your most-valued users and create test accounts with the features you anticipate them to use. If your most-valued users are on dialup or broadband bandwidth speeds, make sure you run performance tests over these types of bandwidth speeds.
5. Quantify and track results – Let’s face it, we all want recognition for good work. There are lots of things we can do to improve the user’s experience. It’s more rewarding when we can quantify those optimizations. Have a portfolio of tools. Quantify performance so that it matches the experience of your users. Understand the differences between the various methodologies and tools your organization uses. If you don’t see an improvement after implementing an optimization, it could be a bad measurement methodology. There are many tools out there and different tools can show you different results. Make sure you are comparing apples to apples. Each tool has its differences, but together they can provide you a complete picture of how your product performs.
6. Set targets – Once you’ve established a methodology to quantify results, set and agree upon a target. Look at your competitors to help you determine a target. Better yet, look at the performance of pages where your users came from. From a quantitative perspective, two pages might take the same amount of time to load but qualitative research has shown us that users’ perception can vary depending on the performance of pages that load right before. Aim high and set a winning target for you, your team, and more importantly, your users.
7. Ask questions and challenge answers – Even smart people make assumptions or repeat incorrect statements. The best thing you can do is ask lots of questions, challenge answers, and if you have time verify the answers yourself. There’s no such thing as a bad question, but there are bad answers. Ask questions that give you the high-level overview. Ask questions that allow you to probe beneath the surface. Where did the information come from? How old is the data? What method was used to obtain the data? What alternative methods were considered and why weren’t they chosen? What assumptions were made? What were the drawbacks to an approach? If there was more time, what else might you have tried? Ask questions before hastily drawing a conclusion.
8. (Bonus) Run YSlow – YSlow analyzes web pages and tells you why they’re slow. Download today and run YSlow on all the pages you visit!
Happy Optimizing and Happy New Year!
[Tenni Theurer is a Product Optimization Manager and manages Yahoo!’s Exceptional Performance team. Tenni has spoken at several conferences including Web 2.0 Exp, The Ajax Experience, The Rich Web Experience, AJAXWorld, BlogHer, and CSDN-DrDobbs. She also blogs regularly on Yahoo! Developer Network and Yahoo! User Interface Blog.]
Posted by tenni at 2:01 PM | Comments (7) | TrackBack
Last week Tenni Theurer, manager of Yahoo!'s Exceptional Performance group and my main performance co-hort, returned from her appearance at the CSDN-Dr.Dobbs Software Developer 2.0 Conference in Beijing, China. This was a big conference, perhaps the biggest software conference ever in China. I was psyched when Tenni told me her talk drew a crowd and was one of the best talks of the conference! CSDN's SD2.0 web site says, "Based on our SD conference survey result, Tenni Theurer’s session ranked as one of the top 3 sessions and was also selected by our editors as the most popular speaker." It's great to see interest in fast web pages has spread worldwide. Upcoming performance performances include the WebGuild Web 2.0 Conference in Santa Clara on January 29 and Velocity, the web performance conference from O'Reilly on June 23-24 near San Francisco.
Steve Souders
Chief Performance Yahoo!
Posted by stevesouders at 4:28 PM | Comments (0)
We're excited to announce the release of YSlow 0.9, Yahoo!'s web page performance analysis tool. There are two big features in this release. By integrating more tightly with Firebug's Net Panel, YSlow now finds non-DOM components such as Ajax requests and image beacons. And YSlow now crawls frames and iframes and analyzes those resources as well. There are several other new features and bug fixes described in the release notes including highlighting 404s, better detection of CSS expressions and JavaScript minification, and searching within the YSlow panel.
These features make YSlow stronger at identifying performance improvements for Web 2.0 applications. It's great that YSlow does even better performance analysis of pages, but be forewarned that your previous YSlow scores will drop if these new-found components exhibit bad performance characteristics. As mentioned in Rule 14 - Make Ajax Cacheable, some of the performance improvements that are readily applied to static content (far future Expires header, gzip compression, minification) can also be applied to Ajax responses. Whether it's Web 1.0 or Web 2.0, YSlow 0.9 helps you figure out what to fix to make your pages faster for your users.
Steve Souders
Stoyan Stefanov
Posted by stevesouders at 8:19 AM | Comments (6)
I get feedback daily on people using YSlow. The emails are all positive, even the ones that report bugs. The best emails describe how YSlow helped a company make their web pages load faster. It was fun to read this article on The Register today: Virgin America tunes up with YSlow. If anyone else has YSlow experiences they wish to share, please post them on the Exceptional Performance Yahoo! group or send them to YSlow feedback.
Steve Souders
Chief Performance Yahoo! and creator of YSlow
Posted by stevesouders at 10:42 AM | Comments (0)
O'Reilly just announced Velocity, their first conference focused on web performance and operations. It's scheduled for June 23-24, 2008 at the San Francisco Airport Marriott in Burlingame. I'm proud to say that Jesse Robbins and I are co-chairing Velocity.
The idea for this conference came after a late night dinner in Seattle with several performance gurus including John Jenkins (Amazon), John Rauser (Farecast), and Nate Moch (Zillow). We had spent the night exchanging ops war stories and performance insights. I hated seeing the night come to an end and promised to find a venue for us and others to gather and share best practices. The idea of learning from other experts and sharing our lessons learned to help others avoid the pitfalls we had already discovered was exciting. JJ, Nate, and I, along with Jesse Robbins and Artur Bergman, met with Tim O'Reilly and Brady Forrest at OSCON and got the ball rolling.
If you're the person your company turns to to keep the web site running, you'll want to make this conference. More importantly, if you're someone who wants to learn from these industry leaders to find out how to make your site fast, scalable, and always available block your calendar for June 23-24. To help make sure we have the most relevant topics and speakers we've gathered an incredible program committee: Artur Bergman (O'Reilly Radar & Wikia), Cal Henderson (Flickr & author of Building Scalable Web Sites), Jon Jenkins (Amazon), and Eric Schurman (Live Search).
Velocity's Call for Participation is now open. We're looking for proposals in the areas of scalability, networking, Ajax performance, database performance, capacity planning, monitoring, and more. See the CFP for the full list. Proposals will be accepted until January 3, 2008.
Registration opens in March 2008. Until then, stay in touch using the official RSS feed. You can also join the Facebook group and Upcoming event. Please use velocity08 when tagging. I hope to see you in June.
Steve Souders
Chief Performance Yahoo!
Posted by stevesouders at 11:26 AM | Comments (3)
Stoyan Stefanov just published an article entitled Web Site Optimization: 13 Simple Steps. People have commented that Yahoo!'s Performance Rules are geared towards large web sites (like Yahoo!). Stoyan's article approaches the best practices from a different angle.
This tutorial takes a practical, example-based approach to implementing those rules. It's targeted towards web developers with a small budget, who are most likely using shared hosting, and working under the various restrictions that come with such a setup.
He also brings up some points that aren't mentioned in Yahoo's best practices, such as:
A quick aside about Stoyan: Stoyan blogs on phpied.com and has co-authored several books including PHP Programming with PEAR and Building Online Communities with phpBB 2. Although he started this article awhile ago, when we saw his work on performance and optimization we asked Stoyan to join the Exceptional Performance team. Now he's a speedfreak with the rest of us! Watch for more news from Stoyan in the future.
Steve Souders
Posted by stevesouders at 9:16 AM | Comments (0)
At Future of Web Apps in London I announced the release of YSlow 0.8. This update includes a few enhancements, but the biggest change is a patch to Firebug's Net Panel. I discovered that resources (scripts, stylesheets, images) read from the browsers cache (with no HTTP traffic) still show up in Net Panel. This has caused confusion when people thought their cacheable components were not actually being cached by the browser. I talked to Joe Hewitt and settled on a fix that comes with this version of YSlow. The full details are found in the article Bug (fix) in Firebug's Net Panel. Enjoy and send your feedback.
Steve Souders
Chief Performance Yahoo!
Posted by stevesouders at 3:47 PM | Comments (3)
People ask whether these performance rules apply to Web 2.0 applications. They definitely do! This rule is the first rule that resulted from working with Web 2.0 applications at Yahoo!.
One of the cited benefits of Ajax is that it provides instantaneous feedback to the user because it requests information asynchronously from the backend web server. However, using Ajax is no guarantee that the user won't be twiddling his thumbs waiting for those asynchronous JavaScript and XML responses to return. In many applications, whether or not the user is kept waiting depends on how Ajax is used. For example, in a web-based email client the user will be kept waiting for the results of an Ajax request to find all the email messages that match their search criteria. It's important to remember that "asynchronous" does not imply "instantaneous".
To improve performance, it's important to optimize these Ajax responses. The most important way to improve the performance of Ajax is to make the responses cacheable, as discussed in Rule 3: Add an Expires Header. Some of the other rules also apply to Ajax:
However, Rule 3 is the most important for speeding up the user experience. Let's look at an example. A Web 2.0 email client might use Ajax to download the user's address book for autocompletion. If the user hasn't modified her address book since the last time she used the email web app, the previous address book response could be read from cache if that Ajax response was made cacheable with a future Expires header. The browser must be informed when to use a previously cached address book response versus requesting a new one. This could be done by adding a timestamp to the address book Ajax URL indicating the last time the user modified her address book, for example, &t=1190241612. If the address book hasn't been modified since the last download, the timestamp will be the same and the address book will be read from the browser's cache eliminating an extra HTTP roundtrip. If the user has modified her address book, the timestamp ensures the new URL doesn't match the cached response, and the browser will request the updated address book entries.
Even though your Ajax responses are created dynamically, and might only be applicable to a single user, they can still be cached. Doing so will make your Web 2.0 apps faster.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 8:51 AM | Comments (14)
Over on Coding Horror, Jeff Atwood writes YSlow: Yahoo's Problems Are Not Your Problems and makes some very good points about not taking YSlow results too literally--at least not without thinking about what you're doing.
But before you run off and implement all of Yahoo's solid advice, consider the audience. These are rules from Yahoo, which according to Alexa is one of the top three web properties in the world. And Rich's company, Topix, is no slouch either-- they're in the top 2,000. It's only natural that Rich would be keenly interested in Yahoo's advice on how to scale a website to millions of unique users per day.
That's good advice when it comes to following any set of recommendations. YSlow was designed for Yahoo's goals and will likely become more general over time. Take it's advice with a grain of salt, just like you should anyone's advice.
The comments on that post contain some useful nuggets as well, including some discussion from Steve Souders and the YSlow creators.
And, if you haven't already seen it, check out our Introducing YSlow screencast which was posted about here.
Jeremy Zawodny
Yahoo! Developer Network
Posted by jzawodn at 7:36 AM | Comments (3)
It's always fun to see what people will do with the tools we release. Sometimes they use them in "interesting" ways. Or, in this case, they're used to come to an amusing conclusion. That's exactly what you'll find in Web 2 Point Slow - Slowcial Communities:
These descriptive statistical data show that successful Web 2.0 communities are pretty slow. This is not necessarily a problem of slow Web servers or Internet connections, but of the amount of data, the number of HTTP requests, too much JavaScript, Flash, images and other media, HTML structure and the time it takes for the browser to render the pages.
Here's the chart:

Luckily, we're not in that slow group. As Ramiro notes "4 sites stand out: yahoo.com and craiglist.org with a grade higher than 90..."
Excellent. :-)
I'm sure this isn't the first time someone will use YSlow to rank some of their favorite sites. Maybe some of those sites will implement of few of our Exceptional Performance Best Practices to speed things up. :-)
Have you seen any particularly surprising results from YSlow so far? Let us know.
Jeremy Zawodny
Yahoo! Developer Network
Posted by jzawodn at 4:04 PM | Comments (3)
During the week of the YSlow release, Dan Theurer and I sat down with Steve Souders (Chief Performance Yahoo) to discuss web site performance and YSlow.
The result of that conversation (and some Camtasia learning on my part) is an audio interview and a video demo for your listening and viewing pleasure.
The 8:51 audio recording (8MB MP3) captures the background discussion, including the need for YSlow, how it came to be, performance best practices, FireBug integration, and so on.
The 8:22 video screencast is a continuation of the discussion where we run YSlow against www.yahoo.com to get an idea of how YSlow works. You can jump right in and watch the video (QuickTime or on-line via JumpCut) without listening to the podcast, but you'll miss a few references from earlier in the discussion.
We also "filmed" two other demos: one using my blog (it gets a "D") and another using the YDN web site (it doesn't score well either). Look for those to appear soon.
Enjoy...
Jeremy Zawodny
Yahoo! Developer Network
Posted by jzawodn at 10:57 AM | Comments (5)
Yahoo! has released YSlow, their web performance tool, on YDN under an open source license. Steve Souders, Yahoo!'s Chief Performance Yahoo!, made the announcement during his session at OSCon.
YSlow measures web page performance based on the best practices evangelized by Yahoo!'s Exceptional Performance team. Since many of these best practices focus on the frontend, YSlow is integrated with Joe Hewitt's Firebug, the web development tool of choice for frontend developers.
YSlow has three main views: Performance, Stats, and Components. Performance view scores the page against each performance rule, generates an overall YSlow grade for the page, and lists specific recommendations for making the page faster. Stats view summarizes the total page weight, cookie size, and HTTP request count. Components view lists each component (image, stylesheet, script, Flash object, etc.) in the page along with HTTP information relevant to page load times. It also contains several tools including JSLint. Try it out!
Posted by stevesouders at 4:31 PM | Comments (10)
Entity tags (ETags) are a mechanism that web servers and browsers use to determine whether the component in the browser's cache matches the one on the origin server. (An "entity" is another word for what I've been calling a "component": images, scripts, stylesheets, etc.) ETags were added to provide a mechanism for validating entities that is more flexible than the last-modified date. An ETag is a string that uniquely identifies a specific version of a component. The only format constraints are that the string be quoted. The origin server specifies the component's ETag using the ETag response header.
HTTP/1.1 200 OK Last-Modified: Tue, 12 Dec 2006 03:03:59 GMT ETag: "10c24bc-4ab-457e1c1f" Content-Length: 12195
Later, if the browser has to validate a component, it uses the If-None-Match header to pass the ETag back to the origin server. If the ETags match, a 304 status code is returned reducing the response by 12195 bytes for this example.
GET /i/yahoo.gif HTTP/1.1 Host: us.yimg.com If-Modified-Since: Tue, 12 Dec 2006 03:03:59 GMT If-None-Match: "10c24bc-4ab-457e1c1f" HTTP/1.1 304 Not Modified
The problem with ETags is that they typically are constructed using attributes that make them unique to a specific server hosting a site. ETags won't match when a browser gets the original component from one server and later tries to validate that component on a different server—a situation that is all too common on web sites that use a cluster of servers to handle requests. By default, both Apache and IIS embed data in the ETag that dramatically reduces the odds of the validity test succeeding on web sites with multiple servers.
The ETag format for Apache 1.3 and 2.x is inode-size-timestamp. Although a given file may reside in the same directory across multiple servers, and have the same file size, permissions, timestamp, etc., its inode is different from one server to the next.
IIS 5.0 and 6.0 have a similar issue with ETags. The format for ETags on IIS is Filetimestamp:ChangeNumber. A ChangeNumber is a counter used to track configuration changes to IIS. It's unlikely that the ChangeNumber is the same across all IIS servers behind a web site.
The end result is ETags generated by Apache and IIS for the exact same component won't match from one server to another. If the ETags don't match, the user doesn't receive the small, fast 304 response that ETags were designed for; instead, they'll get a normal 200 response along with all the data for the component. If you host your web site on just one server, this isn't a problem. But if you have multiple servers hosting your web site, and you're using Apache or IIS with the default ETag configuration, your users are getting slower pages, your servers have a higher load, you're consuming greater bandwidth, and proxies aren't caching your content efficiently. Even if your components have a far future Expires header, a conditional GET request is still made whenever the user hits Reload or Refresh.
If you're not taking advantage of the flexible validation model that ETags provide, it's better to just remove the ETag altogether. The Last-Modified header validates based on the component's timestamp. And removing the ETag reduces the size of the HTTP headers in both the response and subsequent requests. This Microsoft Support article describes how to remove ETags. In Apache, this is done by simply adding the following line to your Apache configuration file:
FileETag none
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 4:06 PM | Comments (42)
It hurts performance to include the same JavaScript file twice in one page. This isn’t as unusual as you might think. A review of the ten top U.S. web sites shows that two of them contain a duplicated script. Two main factors increase the odds of a script being duplicated in a single web page: team size and number of scripts. When it does happen, duplicate scripts hurt performance by creating unnecessary HTTP requests and wasted JavaScript execution.
Unnecessary HTTP requests happen in Internet Explorer, but not in Firefox. In Internet Explorer, if an external script is included twice and is not cacheable, it generates two HTTP requests during page loading. Even if the script is cacheable, extra HTTP requests occur when the user reloads the page.
In addition to generating wasteful HTTP requests, time is wasted evaluating the script multiple times. This redundant JavaScript execution happens in both Firefox and Internet Explorer, regardless of whether the script is cacheable.
One way to avoid accidentally including the same script twice is to implement a script management module in your templating system. The typical way to include a script is to use the SCRIPT tag in your HTML page.
<script type="text/javascript" src="menu_1.0.17.js"></script>
An alternative in PHP would be to create a function called insertScript.
<?php insertScript("menu.js") ?>
In addition to preventing the same script from being inserted multiple times, this function could handle other issues with scripts, such as dependency checking and adding version numbers to script filenames to support far future Expires headers.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 3:39 PM | Comments (4)
Redirects are accomplished using the 301 and 302 status codes. Here’s an example of the HTTP headers in a 301 response.
HTTP/1.1 301 Moved Permanently
Location: http://example.com/newuri
Content-Type: text/html
The browser automatically takes the user to the URL specified in the Location field. All the information necessary for a redirect is in the headers. The body of the response is typically empty. Despite their names, neither a 301 nor a 302 response is cached in practice unless additional headers, such as Expires or Cache-Control, indicate it should be. The meta refresh tag and JavaScript are other ways to direct users to a different URL, but if you must do a redirect, the preferred technique is to use the standard 3xx HTTP status codes, primarily to ensure the back button works correctly.
The main thing to remember is that redirects slow down the user experience. Inserting a redirect between the user and the HTML document delays everything in the page since nothing in the page can be rendered and no components can start being downloaded until the HTML document has arrived.
One of the most wasteful redirects happens frequently and web developers are generally not aware of it. It occurs when a trailing slash (/) is missing from a URL that should otherwise have one. For example, going to http://astrology.yahoo.com/astrology results in a 301 response containing a redirect to http://astrology.yahoo.com/astrology/ (notice the added trailing slash). This is fixed in Apache by using Alias or mod_rewrite, or the DirectorySlash directive if you're using Apache handlers.
Connecting an old web site to a new one is another common use for redirects. Others include connecting different parts of a website and directing the user based on certain conditions (type of browser, type of user account, etc.). Using a redirect to connect two web sites is simple and requires little additional coding. Although using redirects in these situations reduces the complexity for developers, it degrades the user experience. Alternatives for this use of redirects include using Alias and mod_rewrite if the two code paths are hosted on the same server. If a domain name change is the cause of using redirects, an alternative is to create a CNAME (a DNS record that creates an alias pointing from one domain name to another) in combination with Alias or mod_rewrite.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 3:10 PM | Comments (13)
Minification is the practice of removing unnecessary characters from code to reduce its size thereby improving load times. When code is minified all comments are removed, as well as unneeded white space characters (space, newline, and tab). In the case of JavaScript, this improves response time performance because the size of the downloaded file is reduced. Two popular tools for minifying JavaScript code are JSMin and YUI Compressor.
Obfuscation is an alternative optimization that can be applied to source code. Like minification, it removes comments and white space, but it also munges the code. As part of munging, function and variable names are converted into smaller strings making the code more compact as well as harder to read. This is typically done to make it more difficult to reverse engineer the code. But munging can help performance because it reduces the code size beyond what is achieved by minification. The tool-of-choice is less clear in the area of JavaScript obfuscation. Dojo Compressor (ShrinkSafe) is the one I’ve seen used the most.
Minification is a safe, fairly straightforward process. Obfuscation, on the other hand, is more complex and thus more likely to generate bugs as a result of the obfuscation step itself. Obfuscation also requires modifying your code to indicate API functions and other symbols that should not be munged. It also makes it harder to debug your code in production. Although I’ve never seen problems introduced from minification, I have seen bugs caused by obfuscation. In a survey of ten top U.S. web sites, minification achieved a 21% size reduction versus 25% for obfuscation. Although obfuscation has a higher size reduction, I recommend minifying JavaScript code because of the reduced risks and maintenance costs.
In addition to minifying external scripts, inlined script blocks can and should also be minified. Even if you gzip your scripts, as described in Rule 4, minifying them will still reduce the size by 5% or more. As the use and size of JavaScript increases, so will the savings gained by minifying your JavaScript code.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 2:32 PM | Comments (9)
The Domain Name System (DNS) maps hostnames to IP addresses, just as phonebooks map people's names to their phone numbers. When you type www.yahoo.com into your browser, a DNS resolver contacted by the browser returns that server’s IP address. DNS has a cost. It typically takes 20-120 milliseconds for DNS to lookup the IP address for a given hostname. The browser can’t download anything from this hostname until the DNS lookup is completed.
DNS lookups are cached for better performance. This caching can occur on a special caching server, maintained by the user's ISP or local area network, but there is also caching that occurs on the individual user's computer. The DNS information remains in the operating system's DNS cache (the "DNS Client service" on Microsoft Windows). Most browsers have their own caches, separate from the operating system's cache. As long as the browser keeps a DNS record in its own cache, it doesn't bother the operating system with a request for the record.
Internet Explorer caches DNS lookups for 30 minutes by default, as specified by the DnsCacheTimeout registry setting. Firefox caches DNS lookups for 1 minute, controlled by the network.dnsCacheExpiration configuration setting. (Fasterfox changes this to 1 hour.)
When the client’s DNS cache is empty (for both the browser and the operating system), the number of DNS lookups is equal to the number of unique hostnames in the web page. This includes the hostnames used in the page’s URL, images, script files, stylesheets, Flash objects, etc. Reducing the number of unique hostnames reduces the number of DNS lookups.
Reducing the number of unique hostnames has the potential to reduce the amount of parallel downloading that takes place in the page. Avoiding DNS lookups cuts response times, but reducing parallel downloads may increase response times. My guideline is to split these components across at least two but no more than four hostnames. This results in a good compromise between reducing DNS lookups and allowing a high degree of parallel downloads.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 10:42 AM | Comments (9)
Many of these performance rules deal with how external components are managed. However, before these considerations arise you should ask a more basic question: Should JavaScript and CSS be contained in external files, or inlined in the page itself?
Using external files in the real world generally produces faster pages because the JavaScript and CSS files are cached by the browser. JavaScript and CSS that are inlined in HTML documents get downloaded every time the HTML document is requested. This reduces the number of HTTP requests that are needed, but increases the size of the HTML document. On the other hand, if the JavaScript and CSS are in external files cached by the browser, the size of the HTML document is reduced without increasing the number of HTTP requests.
The key factor, then, is the frequency with which external JavaScript and CSS components are cached relative to the number of HTML documents requested. This factor, although difficult to quantify, can be gauged using various metrics. If users on your site have multiple page views per session and many of your pages re-use the same scripts and stylesheets, there is a greater potential benefit from cached external files.
Many web sites fall in the middle of these metrics. For these properties, the best solution generally is to deploy the JavaScript and CSS as external files. The only exception I’ve seen where inlining is preferable is with home pages, such as Yahoo!'s front page (http://www.yahoo.com) and My Yahoo! (http://my.yahoo.com). Home pages that have few (perhaps only one) page view per session may find that inlining JavaScript and CSS results in faster end-user response times.
For front pages that are typically the first of many page views, there are techniques that leverage the reduction of HTTP requests that inlining provides, as well as the caching benefits achieved through using external files. One such technique is to inline JavaScript and CSS in the front page, but dynamically download the external files after the page has finished loading. Subsequent pages would reference the external files that should already be in the browser's cache.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 8:05 PM | Comments (11)
CSS expressions are a powerful (and dangerous) way to set CSS properties dynamically. They’re supported in Internet Explorer, starting with version 5. As an example, the background color could be set to alternate every hour using CSS expressions.
background-color: expression( (new Date()).getHours()%2 ? "#B8D4FF" : "#F08A00" );
As shown here, the expression method accepts a JavaScript expression. The CSS property is set to the result of evaluating the JavaScript expression. The expression method is ignored by other browsers, so it is useful for setting properties in Internet Explorer needed to create a consistent experience across browsers.
The problem with expressions is that they are evaluated more frequently than most people expect. Not only are they evaluated when the page is rendered and resized, but also when the page is scrolled and even when the user moves the mouse over the page. Adding a counter to the CSS expression allows us to keep track of when and how often a CSS expression is evaluated. Moving the mouse around the page can easily generate more than 10,000 evaluations.
One way to reduce the number of times your CSS expression is evaluated is to use one-time expressions, where the first time the expression is evaluated it sets the style property to an explicit value, which replaces the CSS expression. If the style property must be set dynamically throughout the life of the page, using event handlers instead of CSS expressions is an alternative approach. If you must use CSS expressions, remember that they may be evaluated thousands of times and could affect the performance of your page.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 7:52 AM | Comments (5)
Rule 5 described how stylesheets near the bottom of the page prohibit progressive rendering, and how moving them to the document HEAD eliminates the problem. Scripts (external JavaScript files) pose a similar problem, but the solution is just the opposite: it’s better to move scripts from the top to as low in the page as possible. One reason is to enable progressive rendering, but another is to achieve greater download parallelization.
With stylesheets, progressive rendering is blocked until all stylesheets have been downloaded. That’s why it’s best to move stylesheets to the document HEAD, so they get downloaded first and rendering isn’t blocked. With scripts, progressive rendering is blocked for all content below the script. Moving scripts as low in the page as possible means there's more content above the script that is rendered sooner.
The second problem caused by scripts is blocking parallel downloads. The HTTP/1.1 specification suggests that browsers download no more than two components in parallel per hostname. If you serve your images from multiple hostnames, you can get more than two downloads to occur in parallel. (I've gotten Internet Explorer to download over 100 images in parallel.) While a script is downloading, however, the browser won’t start any other downloads, even on different hostnames.
In some situations it’s not easy to move scripts to the bottom. If, for example, the script uses document.write to insert part of the page’s content, it can’t be moved lower in the page. There might also be scoping issues. In many cases, there are ways to workaround these situations.
An alternative suggestion that often comes up is to use deferred scripts. The DEFER attribute indicates that the script does not contain document.write, and is a clue to browsers that they can continue rendering. Unfortunately, Firefox doesn't support the DEFER attribute. In Internet Explorer, the script may be deferred, but not as much as desired. If a script can be deferred, it can also be moved to the bottom of the page. That will make your web pages load faster.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 5:04 PM | Comments (27)
While researching performance at Yahoo!, we discovered that moving stylesheets to the document HEAD makes pages load faster. This is because putting stylesheets in the HEAD allows the page to render progressively.
Front-end engineers that care about performance want a page to load progressively; that is, we want the browser to display whatever content it has as soon as possible. This is especially important for pages with a lot of content and for users on slower Internet connections. The importance of giving users visual feedback, such as progress indicators, has been well researched and documented. In our case the HTML page is the progress indicator! When the browser loads the page progressively the header, the navigation bar, the logo at the top, etc. all serve as visual feedback for the user who is waiting for the page. This improves the overall user experience.
The problem with putting stylesheets near the bottom of the document is that it prohibits progressive rendering in many browsers, including Internet Explorer. Browsers block rendering to avoid having to redraw elements of the page if their styles change. The user is stuck viewing a blank white page. Firefox doesn't block rendering, which means when the stylesheet is done loading it's possible elements in the page will have to be redrawn, resulting in the flash of unstyled content problem.
The HTML specification clearly states that stylesheets are to be included in the HEAD of the page: "Unlike A, [LINK] may only appear in the HEAD section of a document, although it may appear any number of times." Neither of the alternatives, the blank white screen or flash of unstyled content, are worth the risk. The optimal solution is to follow the HTML specification and load your stylesheets in the document HEAD.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 12:26 PM | Comments (17)
The time it takes to transfer an HTTP request and response across the network can be significantly reduced by decisions made by front-end engineers. It’s true that the end-user’s bandwidth speed, Internet service provider, proximity to peering exchange points, etc. are beyond the control of the development team. But there are other variables that affect response times. Compression reduces response times by reducing the size of the HTTP response.
Starting with HTTP/1.1, web clients indicate support for compression with the Accept-Encoding header in the HTTP request.
Accept-Encoding: gzip, deflate
If the web server sees this header in the request, it may compress the response using one of the methods listed by the client. The web server notifies the web client of this via the Content-Encoding header in the response.
Content-Encoding: gzip
Gzip is the most popular and effective compression method at this time. It was developed by the GNU project and standardized by RFC 1952. The only other compression format you’re likely to see is deflate, but it’s less effective and less popular.
Gzipping generally reduces the response size by about 70%. Approximately 90% of today’s Internet traffic travels through browsers that claim to support gzip. If you use Apache, the module configuring gzip depends on your version: Apache 1.3 uses mod_gzip while Apache 2.x uses mod_deflate.
There are known issues with browsers and proxies that may cause a mismatch in what the browser expects and what it receives with regard to compressed content. Fortunately, these edge cases are dwindling as the use of older browsers drops off. The Apache modules help out by adding appropriate Vary response headers automatically.
Servers choose what to gzip based on file type, but are typically too limited in what they decide to compress. Most web sites gzip their HTML documents. It’s also worthwhile to gzip your scripts and stylesheets, but many web sites miss this opportunity. In fact, it’s worthwhile to compress any text response including XML and JSON. Image and PDF files should not be gzipped because they are already compressed. Trying to gzip them not only wastes CPU but can potentially increase file sizes.
Gzipping as many file types as possible is an easy way to reduce page weight and accelerate the user experience.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 1:24 PM | Comments (64)
Web page designs are getting richer and richer, which means more scripts, stylesheets, images, and Flash in the page. A first-time visitor to your page may have to make several HTTP requests, but by using the Expires header you make those components cacheable. This avoids unnecessary HTTP requests on subsequent page views. Expires headers are most often used with images, but they should be used on all components including scripts, stylesheets, and Flash components.
Browsers (and proxies) use a cache to reduce the number and size of HTTP requests, making web pages load faster. A web server uses the Expires header in the HTTP response to tell the client how long a component can be cached. This is a far future Expires header, telling the browser that this response won’t be stale until April 15, 2010.
Expires: Thu, 15 Apr 2010 20:00:00 GMT
If your server is Apache, use the ExiresDefault directive to set an expiration date relative to the current date. This example of the ExpiresDefault directive sets the Expires date 10 years out from the time of the request.
ExpiresDefault "access plus 10 years"
Keep in mind, if you use a far future Expires header you have to change the component’s filename whenever the component changes. At Yahoo! we often make this step part of the build process: a version number is embedded in the component’s filename, for example, yahoo_2.0.6.js.
Using a far future Expires header affects page views only after a user has already visited your site. It has no effect on the number of HTTP requests when a user visits your site for the first time and the browser’s cache is empty. The impact of this performance improvement depends, therefore, on how often users hit your pages with a primed cache. (A "primed cache" already contains all of the components in the page.) We measured this at Yahoo! and found the number of page views with a primed cache is 75-85%. By using a far future Expires header, you increase the number of components that are cached by the browser and re-used on subsequent page views without sending a single byte over the user’s Internet connection.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 11:10 AM | Comments (64)
The user's proximity to your web server has an impact on response times. Deploying your content across multiple, geographically dispersed servers will make your pages load faster from the user's perspective. But where should you start?
As a first step to implementing geographically dispersed content, don't attempt to redesign your web application to work in a distributed architecture. Depending on the application, changing the architecture could include daunting tasks such as synchronizing session state and replicating database transactions across server locations. Attempts to reduce the distance between users and your content could be delayed by, or never pass, this application architecture step.
Remember that 80-90% of the end-user response time is spent downloading all the components in the page: images, stylesheets, scripts, Flash, etc. This is the Performance Golden Rule, as explained in The Importance of Front-End Performance. Rather than starting with the difficult task of redesigning your application architecture, it's better to first disperse your static content. This not only achieves a bigger reduction in response times, but it's easier thanks to content delivery networks.
A content delivery network (CDN) is a collection of web servers distributed across multiple locations to deliver content more efficiently to users. The server selected for delivering content to a specific user is typically based on a measure of network proximity. For example, the server with the fewest network hops or the server with the quickest response time is chosen.
Some large Internet companies own their own CDN, but it's cost-effective to use a CDN service provider, such as Akamai Technologies, Mirror Image Internet, or Limelight Networks. For start-up companies and private web sites, the cost of a CDN service can be prohibitive, but as your target audience grows larger and becomes more global, a CDN is necessary to achieve fast response times. At Yahoo!, properties that moved static content off their application web servers to a CDN improved end-user response times by 20% or more. Switching to a CDN is a relatively easy code change that will dramatically improve the speed of your web site.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 9:03 AM | Comments (31)
In The Importance of Front-End Performance, I reveal that 80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, stylesheets, scripts, Flash, etc. Reducing the number of components in turn reduces the number of HTTP requests required to render the page. This is the key to faster pages.
One way to reduce the number of components in the page is to simplify the page's design. But is there a way to build pages with richer content while also achieving fast response times? Here are some techniques for reducing the number of HTTP requests, while still supporting rich page designs.
Image maps combine multiple images into a single image. The overall size is about the same, but reducing the number of HTTP requests speeds up the page. Image maps only work if the images are contiguous in the page, such as a navigation bar. Defining the coordinates of image maps can be tedious and error prone.
CSS Sprites are the preferred method for reducing the number of image requests. Combine all the images in your page into a single image and use the CSS background-image and background-position properties to display the desired image segment.
Inline images use the data: URL scheme to embed the image data in the actual page. This can increase the size of your HTML document. Combining inline images into your (cached) stylesheets is a way to reduce HTTP requests and avoid increasing the size of your pages.
Combined files are a way to reduce the number of HTTP requests by combining all scripts into a single script, and similarly combining all stylesheets into a single stylesheet. It's a simple idea that hasn't seen wide adoption. The ten top U.S. web sites average 7 scripts and 2 stylesheets per page. Combining files is more challenging when the scripts and stylesheets vary from page to page, but making this part of your release process improves response times.
Reducing the number of HTTP requests in your page is the place to start. This is the most important guideline for improving performance for first time visitors. As described in Tenni Theurer's blog Browser Cache Usage - Exposed!, 40-60% of daily visitors to your site come in with an empty cache. Making your page fast for these first time visitors is key to a better user experience.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 9:41 AM | Comments (35)
In 2004, I started the Exceptional Performance group at Yahoo!. We're a small team chartered to measure and improve the performance of Yahoo!'s products. Having worked as a back-end engineer most of my career, I approached this as I would a code optimization project - I profiled web performance to identify where there was the greatest opportunity for improvement. Since our goal is to improve the end-user experience, I measured response times in a browser over various bandwidth speeds. What I saw is illustrated in the following chart showing HTTP traffic for http://www.yahoo.com.

In the figure above, the first bar, labeled "html", is the initial request for the HTML document. In this case, only 5% of the end-user response time is spent fetching the HTML document. This result holds true for almost all web sites. In sampling the top ten U.S. websites, all but one spend less than 20% of the total response time getting the HTML document. The other 80+% of the time is spent dealing with what's in the HTML document, namely, the front-end. That's why the key to faster web sites is to focus on improving front-end performance.
There are three main reasons why front-end performance is the place to start.
Our performance golden rule is: optimize front-end performance first, that's where 80% or more of the end-user response time is spent.
Steve Souders
[Steve Souders is Yahoo!'s Chief Performance Yahoo!. This is one in a series of Best Practices for Speeding Up Your Web Site. This article is based on Steve's book High Performance Web Sites, published by O'Reilly.]
Posted by stevesouders at 9:16 AM | Comments (22)
Copyright © 2008 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings