1 / 30

Even Faster Web Sites

Even Faster Web Sites. http://stevesouders.com/docs/wikipedia-20090812.ppt Disclaimer: This content does not necessarily reflect the opinions of my employer. the importance of frontend performance. 9%. 91%. 17%. 83%. iGoogle, primed cache. iGoogle, empty cache. Make fewer HTTP requests

olympia
Télécharger la présentation

Even Faster Web Sites

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Even Faster Web Sites http://stevesouders.com/docs/wikipedia-20090812.ppt Disclaimer: This content does not necessarily reflect the opinions of my employer.

  2. the importance of frontend performance 9% 91% 17% 83% iGoogle, primed cache iGoogle, empty cache

  3. Make fewer HTTP requests • Use a CDN • Add an Expires header • Gzip components • Put stylesheets at the top • Put scripts at the bottom • Avoid CSS expressions • Make JS and CSS external • Reduce DNS lookups • Minify JS • Avoid redirects • Remove duplicate scripts • Configure ETags • Make AJAX cacheable 14 Rules

  4. Even Faster Web Sites Splitting the initial payload Loading scripts without blocking Coupling asynchronous scripts Positioning inline scripts Sharding dominant domains Flushing the document early Using iframes sparingly Simplifying CSS Selectors Understanding Ajax performance..........Doug Crockford Creating responsive web apps............Ben Galbraith, Dion Almaer Writing efficient JavaScript.............Nicholas Zakas Scaling with Comet.....................Dylan Schiemann Going beyond gzipping...............Tony Gentilcore Optimizing images...................Stoyan Stefanov, Nicole Sullivan

  5. Why focus on JavaScript? Yahoo! Wikipedia eBay AOL MySpace YouTube Facebook

  6. scripts block <script src="A.js"> blocks parallel downloads and rendering 9 secs: IE 6-7, FF 3.0, Chr 1, Op 9-10, Saf 3 7 secs: IE 8, FF 3.5(?), Chr 2, Saf 4

  7. initial payload and execution 26% avg 252K avg

  8. splitting the initial payload split your JavaScript between what's needed to render the page and everything else load "everything else" after the page is rendered separate manually (Page Speed); tools needed to automate this (Doloto) load scripts without blocking – how?

  9. MSN.com: parallel scripts MSN Scripts and other resources downloaded in parallel! How? Secret sauce?! var p= g.getElementsByTagName("HEAD")[0]; var c=g.createElement("script"); c.type="text/javascript"; c.onreadystatechange=n; c.onerror=c.onload=k; c.src=e; p.appendChild(c)

  10. Loading Scripts Without Blocking XHR Eval XHR Injection Script in Iframe Script DOM Element Script Defer document.write Script Tag

  11. browser busy indicators

  12. Load Scripts Without Blocking *Only other document.write scripts are downloaded in parallel (in the same script block).

  13. and the winner is... XHR Eval XHR Injection Script in iframe Script DOM Element Script Defer same domains different domains Script DOM Element Script Defer no order preserve order XHR Eval XHR Injection Script in iframe Script DOM Element (IE) Script DOM Element (FF) Script Defer (IE) Managed XHR Eval Managed XHR Injection no order preserve order Script DOM Element no busy show busy Script DOM Element (FF) Script Defer (IE) Managed XHR Injection Managed XHR Eval Script DOM Element (FF) Script Defer (IE) Managed XHR Eval Managed XHR Injection no busy show busy XHR Injection XHR Eval Script DOM Element (IE) Managed XHR Injection Managed XHR Eval Script DOM Element

  14. Loading Scripts Without Blocking don't let scripts block other downloads you can still control execution order, busy indicators, and onload event What about inline scripts?

  15. bad: stylesheet followed by inline script browsers download stylesheets in parallel with other resources that follow... ...unless the stylesheet is followed by an inline script http://stevesouders.com/cuzillion/?ex=10021 best to move inline scripts above stylesheets or below other resources use Link, not @import

  16. mispositioned inline scripts MSN Wikipedia eBay MySpace

  17. going beyond gzipping Tony Gentilcore, Chapter 9, Even Faster Web Sites Rule 4: Gzip Components from HPWS HTTP/1.1 • request: Accept-Encoding: gzip,deflate • response: Content-Encoding: gzip Apache 2.x: • AddOutputFilterByType DEFLATE text/html text/css application/x-javascript

  18. benefits of gzipping 70% reduction in transfer size not just for HTML!! • all text: JavaScript, CSS, XML, JSON • not binary: images, PDF, Flash

  19. so what's the issue? 15% of users get uncompressed responses surprize! why? old browsers? no • Netscape Navigator 3 – 0.0% • Netscape Communicator 4 – 0.1% • Opera 3.5 – 0.0% • IE <3 – 0.01% clue: most prevalent in the Middle East

  20. who's stripping? proxies and anti-virus software disable compression for easier response filtering

  21. what to do Thanks, Tony! see Tony's chapter in Even Faster Web Sites don't assume compression go the extra mile to reduce response size • event delegation (-5%)* • relative URLs (-3%) • minify HTML, JavaScript, and CSS (-4%) • use CSS rules over inline styles (-1%) • alias long JavaScript symbol names (??) * Results of applying each technique to the Alexa top ten

  22. White Dwarf http://en.wikipedia.org/wiki/White_dwarf

  23. White Dwarf combine stylesheets remove unused CSS (50%) sprite 8 bg images combine scripts minify (36K, 36%) move lower load async 81% deferrable move inline script add Expires to upload.w.o don't use querystring: ?233yz http://en.wikipedia.org/wiki/White_dwarf

  24. combine stylesheets remove unused CSS (50%) move inline script combine scripts minify (44K, 35%) move lower load async 76% deferrable add Expires to upload.w.o don't use querystring: ?233yz don't change URL: 233yz v 233zz

  25. takeaways focus on the frontend run YSlow (http://developer.yahoo.com/yslow) and Page Speed! (http://code.google.com/speed/page-speed/) speed matters

  26. impact on revenue +2000 ms  -4.3% revenue/user1 +400 ms  -5-9% full-page traffic2 +400 ms  -0.59% searches/user1 fastest users+50% page views3 -5000 ms +7-12% revenue4 1 http://en.oreilly.com/velocity2009/public/schedule/detail/8523 2 http://www.slideshare.net/stoyan/yslow-20-presentation 3 http://en.oreilly.com/velocity2009/public/schedule/detail/7579 4 http://en.oreilly.com/velocity2009/public/schedule/detail/7709 Bing: Yahoo: Google: AOL: Shopzilla:

  27. cost savings hardware – reduced load • Shopzilla – 50% fewer servers bandwidth – reduced response size http://billwscott.com/share/presentations/2008/stanford/HPWP-RealWorld.pdf

  28. if you want • better user experience • more revenue • reduced operating expenses the strategy is clear Even Faster Web Sites

  29. Steve Souders souders@google.com http://stevesouders.com/docs/wikipedia-20090812.ppt

More Related