Presentation is loading. Please wait.

Presentation is loading. Please wait.

High Performance Web Sites 14 rules for faster pages Steve Souders Chief Performance Yahoo!

Similar presentations

Presentation on theme: "High Performance Web Sites 14 rules for faster pages Steve Souders Chief Performance Yahoo!"— Presentation transcript:

1 High Performance Web Sites 14 rules for faster pages Steve Souders Chief Performance Yahoo!

2 Exceptional Performance quantify and improve the performance of all Yahoo! products worldwide center of expertise build tools, analyze data gather, research, and evangelize best practices

3 The Importance of Frontend Performance Backend = 5% Frontend = 95% Even primed cache, frontend = 88%

4 Time Spent on the Frontend Empty CachePrimed Cache amazon.com82%86% aol.com94%86% cnn.com81%92% ebay.com98%92% google.com86%64% msn.com97%95% myspace.com96%86% wikipedia.org80%88% yahoo.com95%88% youtube.com97%95%

5 The Performance Golden Rule 80-90% of the end-user response time is spent on the frontend. Start there. Greater potential for improvement Simpler Proven to work

6 Performance Research What the 80/20 Rules Tells Us about Reducing HTTP requests Browser Cache Usage – Exposed When the Cookie Crumbles Maximizing Parallel Downloads in the Carpool Lane

7 Browser Cache Experiment Add an image to the page: Expires: Thu, 15 Apr :00:00 GMT Last-Modified: Wed, 28 Sep :49:57 GMT # users with at least one 200 response total # unique users Percentage of users with an empty cache? Percentage of page views with an empty cache? # of 200 responses total # responses

8 Browser Cache Expt Results page views with empty cache 40-60% ~20% users with empty cache

9 Experiment Takeaways The empty cache user experience is more prevalent than you think! Optimize for both primed cache and empty cache experience.

10 14 Rules

11 1.Make fewer HTTP requests 2.Use a CDN 3.Add an Expires header 4.Gzip components 5.Put stylesheets at the top 6.Move scripts to the bottom 7.Avoid CSS expressions 8.Make JS and CSS external 9.Reduce DNS lookups 10.Minify JS 11.Avoid redirects 12.Remove duplicate scripts 13.Configure ETags 14.Make AJAX cacheable

12 Rule 1: Make fewer HTTP requests CSS sprites combined scripts, combined stylesheets image maps inline images

13 CSS Sprites size of combined image is less

14 Rule 2: Use a CDN distribute your static content before distributing your dynamic content amazon.comAkamai aol.comAkamai ebay.comAkamai, Mirror Image msn.comSAVVIS myspace.comAkamai, Limelight yahoo.comAkamai

15 Rule 3: Add an Expires header not just for images ImagesStylesheetsScripts % with Expires Median Age amazon.com0/620/10/30%114 days aol.com23/431/16/1848%217 days cnn.com0/1380/22/111%227 days ebay.com16/200/20/755%140 days 4%454 days msn.com32/351/13/980%34 days myspace.com0/180/2 0%1 day wikipedia.org6/81/12/375%1 day yahoo.com23/231/14/4100%n/a youtube.com0/320/30/70%26 days

16 Rule 4: Gzip components you can affect users' download times 90%+ of browsers support compression

17 Gzip: not just for HTML HTMLScriptsStylesheets amazon.comx aol.comxsome ebay.comx msn.comxdeflate myspace.comxxx wikipedia.orgxxx yahoo.comxxx youtube.comxsome gzip scripts, stylesheets, XML, JSON (not images, PDF)

18 Rule 5: Put stylesheets at the top stylesheets block rendering in IE solution: put stylesheets in HEAD (per spec) avoids Flash of Unstyled Content use LINK

19 Rule 6: Move scripts to the bottom scripts block parallel downloads across all hostnames scripts block rendering of everything below them in the page script defer attribute is not a solution –blocks rendering and downloads in FF –slight blocking in IE

20 Rule 7: Avoid CSS expressions used to set CSS properties dynamically in IE width: expression( document.body.clientWidth < 600 ? 600px : auto ); problem: expressions execute many times –mouse move, key press, resize, scroll, etc. alternatives: –one-time expressions –event handlers

21 Rule 8: Make JS and CSS external inline: HTML document is bigger external: more HTTP requests, but cached variables –page views per user (per session) –empty vs. primed cache stats –component re-use external is typically better extra credit: post-onload download, dynamic inlining

22 Rule 9: Reduce DNS lookups typically ms block parallel downloads OS and browser both have DNS caches

23 minify inline scripts, too Rule 10: Minify JavaScript Minify External? Minify Inline?

24 Minify vs. Obfuscate OriginalJSMin SavingsDojo Savings (15%)48K (24%) (10%) (20%)24K (25%) (27%)24K (28%) (34%)16K (38%) (22%)10K (29%) Average85K17K (21%)21K (25%) minify – it's safer not much difference

25 Rule 11: Avoid redirects 3xx status codes – mostly 301 and 302 HTTP/ Moved Permanently Location: add Expires headers to cache redirects worst form of blocking

26 Rule 12: Remove duplicate scripts hurts performance –extra HTTP requests (IE only) –extra executions atypical? –2 of 10 top sites contain duplicate scripts team size, # of scripts

27 Rule 13: Configure ETags unique identifier returned in response ETag: "c8897e-aee-4165acf0" Last-Modified: Thu, 07 Oct :54:08 GMT used in conditional GET requests If-None-Match: "c8897e-aee-4165acf0" If-Modified-Since: Thu, 07 Oct :54:08 GMT if ETag doesn't match, can't send 304 ETag format –Apache: inode-size-timestamp –IIS: Filetimestamp:ChangeNumber Use 'em or lose 'em –Apache: FileETag none –IIS:

28 Rule 14: Make AJAX cacheable XHR, JSON, iframe, dynamic scripts can still be cached (and minified, and gzipped) a personalized response should still be cacheable for that person

29 Next Rules split dominant content domains reduce cookie weight make static content cookie-free minify CSS use iframes wisely optimize images

30 Case Studies

31 Case Study: move JS to onload remove bottom tabs avoid redirects images sprites host JS on CDN combine JS files 40-50%

32 Evangelism Book High Performance Web Sites Conferences Yahoo! F2E Summit Web 2.0 Expo Rich Web Experience Blogs YUI Blog: YDN Blog: YSlow OSCon Ajax Experience Blogher Future of Web Apps

33 YSlow performance lint tool grades web pages for each rule Firefox add-on integrated with Firebug open source license


35 Ten Top U.S Web Sites Page Weight Response Time YSlow Grade secD secF secF secC secA secF secD secC secA secD

36 Strong Correlation total page weight response time inverse YSlow grade correlation(resp time, page weight) = 0.94 correlation(resp time, inverse YSlow) = 0.76

37 Live Analysis

38 Takeaways focus on the frontend harvest the low-hanging fruit small investment up front keeps on giving you do control user response times LOFNO – be an advocate for your users

39 Steve Souders

40 CC Images Used "Need for Speed" by Amnemona: "Max speed 15kmh" by xxxtoff: "maybe" by Tal Bright: "takeout" by dotpolka: "Absolutely Nothing is Allowed Here" by Vicki & Chuck Rogers: "Zipper Pocket" by jogales: "Robert's Legion" by dancharvey: "thank you" by nj dodge: "new briefcase" by dcJohn:

Download ppt "High Performance Web Sites 14 rules for faster pages Steve Souders Chief Performance Yahoo!"

Similar presentations

Ads by Google