Widget Summit 2008

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Notes on slide 1

    Permission to use photo given by Amnemona: http://www.flickr.com/photos/marinacvinhal/379111290/

    1 Favorite

    Widget Summit 2008 - Presentation Transcript

    1. Steve Souders [email_address] http://stevesouders.com/docs/widget-summit-2008.ppt High Performance Widgets Disclaimer: This content does not necessarily reflect the opinions of my employer.
    2. The Importance of Frontend Performance 17% 83% iGoogle, primed cache 9% 91% iGoogle, empty cache
    3. Time Spent on the Frontend April 2008 Empty Cache Primed Cache www.aol.com 97% 97% www.ebay.com 95% 81% www.facebook.com 95% 81% www.google.com/search 47% 0% search.live.com/results 67% 0% www.msn.com 98% 94% www.myspace.com 98% 98% en.wikipedia.org/wiki 94% 91% www.yahoo.com 97% 96% www.youtube.com 98% 97%
    4. 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
    5. 14 Rules
      • 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
    6. High Performance Web Sites YSlow
      • http://conferences.oreilly.com/velocity/
      June 22-24, 2009
    7.  
    8. High Performance Web Sites, Vol 2
      • Split the initial payload
      • Load scripts without blocking
      • Don't scatter inline scripts
      • Split dominant domains
      • Make static content cookie-free
      • Reduce cookie weight
      • Minify CSS
      • Optimize images
      • Use iframes sparingly
      • To www or not to www
    9. Why focus on JavaScript? AOL eBay Facebook MySpace Wikipedia Yahoo! YouTube
    10. Scripts Block <script src=&quot;A.js&quot;> blocks parallel downloads and rendering What's &quot;Cuzillion&quot;? http://stevesouders.com/cuzillion/?ex=10008
    11. Initial Payload and Execution 26% avg 252K avg JavaScript Functions Executed before onload www.aol.com 115K 30% www.ebay.com 183K 44% www.facebook.com 1088K 9% www.google.com/search 15K 45% search.live.com/results 17K 24% www.msn.com 131K 31% www.myspace.com 297K 18% en.wikipedia.org/wiki 114K 32% www.yahoo.com 321K 13% www.youtube.com 240K 18%
    12. Split the initial payload split your JavaScript between what's needed to render the page and everything else load &quot;everything else&quot; after the page is rendered separate manually (Firebug); tools needed to automate this (Doloto from Microsoft) load scripts without blocking – how?
    13. MSN.com: Parallel Scripts Scripts and other resources downloaded in parallel! How? Secret sauce?! var p= g.getElementsByTagName(&quot;HEAD&quot;)[0]; var c=g.createElement(&quot;script&quot;); c.type=&quot;text/javascript&quot;; c.onreadystatechange=n; c.onerror=c.onload=k; c.src=e; p.appendChild(c) MSN
    14. Advanced Script Loading XHR Eval XHR Injection Script in Iframe Script DOM Element Script Defer document.write Script Tag
    15. XHR Eval script must have same domain as main page must refactor script var xhrObj = getXHRObject(); xhrObj.onreadystatechange = function() { if ( xhrObj.readyState != 4 ) return; eval(xhrObj.responseText); }; xhrObj.open('GET', 'A.js', true); xhrObj.send(''); http://stevesouders.com/cuzillion/?ex=10009
    16. XHR Injection var xhrObj = getXHRObject(); xhrObj.onreadystatechange = function() { if ( xhrObj.readyState != 4 ) return; var se=document.createElement('script'); document.getElementsByTagName('head') [0].appendChild(se); se.text = xhrObj.responseText; }; xhrObj.open('GET', 'A.js', true); xhrObj.send(''); script must have same domain as main page http://stevesouders.com/cuzillion/?ex=10015
    17. Script in Iframe <iframe src='A.html' width=0 height=0 frameborder=0 id=frame1></iframe>
      • iframe must have same domain as main page
      • must refactor script:
        • // access iframe from main page
        • window.frames[0].createNewDiv();
        • // access main page from iframe
        • parent.document.createElement('div');
      http://stevesouders.com/cuzillion/?ex=10012
    18. Script DOM Element var se = document.createElement('script'); se.src = 'http://anydomain.com/A.js'; document.getElementsByTagName('head') [0].appendChild(se); script and main page domains can differ no need to refactor JavaScript http://stevesouders.com/cuzillion/?ex=10010
    19. Script Defer <script defer src='A.js'></script> only supported in IE (just landed in FF 3.1) script and main page domains can differ no need to refactor JavaScript http://stevesouders.com/cuzillion/?ex=10013
    20. document.write Script Tag document.write (&quot;<scr&quot; + &quot;ipt type='text/javascript' src='A.js'>&quot; + &quot;</scr&quot; + &quot;ipt>&quot;); parallelization only works in IE parallel downloads for scripts, nothing else all document.write s must be in same script block http://stevesouders.com/cuzillion/?ex=10014
    21. Browser Busy Indicators
    22. Browser Busy Indicators good to show busy indicators when the user needs feedback bad when downloading in the background
    23. Ensure/Avoid Ordered Execution
      • Ensure scripts execute in order:
        • necessary when scripts have dependencies
        • IE: http://stevesouders.com/cuzillion/?ex=10017
        • FF: http://stevesouders.com/cuzillion/?ex=10018
      • Avoid scripts executing in order:
        • faster – first script back is executed immediately
        • http://stevesouders.com/cuzillion/?ex=10019
    24. Summary of Traits * Only other document.write scripts are downloaded in parallel (in the same script block).
    25. and the winner is... XHR Eval XHR Injection Script in iframe Script DOM Element Script Defer Script DOM Element Script Defer Script DOM Element Script DOM Element (FF) Script Defer (IE) XHR Eval XHR Injection Script in iframe Script DOM Element (IE) XHR Injection XHR Eval Script DOM Element (IE) Managed XHR Injection Managed XHR Eval Script DOM Element Managed XHR Injection Managed XHR Eval Script DOM Element (FF) Script Defer (IE) Managed XHR Eval Managed XHR Injection Script DOM Element (FF) Script Defer (IE) Managed XHR Eval Managed XHR Injection different domains same domains no order preserve order no order no busy show busy show busy no busy preserve order
    26. Load Scripts without Blocking
      • don't let scripts block other downloads
      • you can still control execution order, busy indicators, and onload event
    27. Inline Scripts Block
      • long executing inline scripts block rendering and downloads
      • http://stevesouders.com/cuzillion/?ex=10035
      • workarounds:
        • initiate execution with setTimeout (>250 for FF, nglayout.initialpaint.delay )
        • move JavaScript to external script with advanced downloading techniques
        • use Defer attribute (IE only)
    28. Inline Scripts after Stylesheets Block Downloading
      • Firefox 3 and IE download stylesheets in parallel
      • ...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
    29. Examples of Scattered Scripts eBay MSN MySpace Wikipedia
    30. Don't Scatter Inline Scripts remember inline scripts carry a cost avoid long-executing inline scripts don't put inline scripts between stylesheets and other resources
    31. Get Satisfaction Widget
    32. Get Satisfaction Widget
      • <div id=&quot;gsfn_content&quot;>Loading...</div>
      • <script _ src=&quot;http://getsatisfaction.com/oreilly/widgets/javascripts/5977e91/widgets.js&quot; type=&quot;text/javascript&quot;></script>
      • <script _ src=&quot;http://getsatisfaction.com/oreilly/topics.widget?callback=gsfnTopicsCallback&amp;length=120&amp;limit=5&amp;sort=recently_active&quot; type=&quot;text/javascript&quot;></script>
      • ...
      • function gsfn_populate(id, template) {
      • document.getElementById(id).innerHTML = template;
      • }
      • good
        • small
      • improve
        • add future Expires header – widgets.js, favicon.gif (not topics.widget)
        • gzip – wigets.js, topics.widget
        • minify widgets.js
        • remove ETags
        • use only one: getsatisfaction.com or www.getsatisfaction.com
        • load scripts async
      3 requests 8K xfer size 8K JS (uncompr)
    33. Google Calendar Widget
    34. Google Calendar Widget
      • <iframe _
      • src=&quot;//www.google.com/calendar/embed
        • ?mode=AGENDA
        • &amp;height=600
        • &amp;wkst=1
        • &amp;bgcolor=%23FFFFFF
        • &amp;src=v9ke3029e8k53qjtbf506jumu8ktapjh%40import.calendar.google.com
        • &amp;color=%235A6986
        • &amp;ctz=America%2FLos_Angeles&quot;
      • style=&quot; border-width:0 &quot; width=&quot;800&quot; height=&quot;600&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot;>
      • </iframe>
      • good
        • gzip turned on
        • no ETags
        • future Expires headers
      • improve
        • big! 135K JS, 18K CSS (uncompressed)
        • set iframe SRC dynamically
        • 44% of JS unused
        • sprite 6 images into 1
        • /feeds/ is slow (only 2K, but longer than 133K JS)
      10 requests 65K xfer size 135K JS (uncompr)
    35. Google Friend Connect Widget
    36. Google Friend Connect Widget
      • <div id=&quot;div-08054659623916314855-members&quot;></div>
      • <script type=&quot;text/javascript&quot;>
      • var skin = {};
      • skin['HEIGHT'] = '150';
      • skin['HEADER_FOOTER_BG_COLOR'] = '#BFEECC';
      • skin['MEMBERS_LIST_BG_COLOR'] = '#D9FFE4';
      • skin['MEMBERS_LIST_FRIEND_LINK_COLOR'] = '#339966';
      • skin['MEMBERS_LIST_HEADER_FONT_COLOR'] = '#339966';
      • skin['INVITE_LINK_COLOR'] = '#339966';
      • google.friendconnect.container.renderMembersGadget( { id: 'div-08054659623916314855-members', site: '08054659623916314855' }, skin);
      • </script>
    37. 39 requests 188K xfer size 471K JS (uncompr) (3 widgets)
      • good
        • gzip turned on
        • no ETags
        • future Expires headers
      • improve
        • big! (really 3 widgets)
        • 3 redirects – max-age=0
        • 74% of JS unused
        • 22 requests expire in 24 hours
        • 173K of images – lossless compression cuts 87%
        • 4 text/html responses not gzipped (total 19K)
        • 6 CSS expressions
        • 3 duplicate scripts – iframes
      39 requests 188K xfer size 471K JS (uncompr) (3 widgets)
    38. MyBlogLog Widget
    39. MyBlogLog Widget
      • var mbl_widget = '';
      • mbl_widget += '';
      • mbl_widget += ' <style>';
      • mbl_widget += ' a.mbl_widget {…}';
      • mbl_widget += ' a.mbl_widget_u {…}';
      • mbl_widget += ' a.mbl_widget_a {…}';
      • mbl_widget += '';
      • [321 lines later...]
      • mbl_widget += ' </div>';
      • mbl_widget += ' </div>';
      • mbl_widget += '';
      • document.write(mbl_widget);
      • good
        • sprite (v3_1_default_black.gif)
        • domain sharding
        • images optimized
      • improve
        • add future Expires (nopic_48.gif, close12_1.gif)
        • 5 DNS lookups
        • avoid document.write
        • 80% of JS unused
        • load script asynchronously
      js 14 requests 60K xfer size 62K JS (uncompr)
    40. Plaxo Widget
    41. Plaxo Widget
      • <div id=&quot;plaxo-pulse-widget&quot;></div>
      • <script _ src=&quot;http://pulse.plaxo.com/pulse/widget/get?authTicket=265...4%3D&amp;type=frame&amp;version=2&amp;height=480&amp;width=125&quot;></script>
      • iframe is appended to div
      • good
        • 10 day future Expires
        • gzip enabled
        • domain sharding (Flickr)
        • backend stitching
      • improve
        • /badge is slow – start with previous request
        • do away with iframe altogether – one script
        • load script asynchronously – set size of div
        • 4 images could be sprited into 1
      js 14 requests 41K xfer size 2K JS (uncompr)
    42. Announcement 1: UA Profiler
      • tracks browser performance traits
      • http://stevesouders.com/ua/
      • go to the test page
      • your browser automatically walks through the tests (requires JS)
      • results recorded and shared publicly
      • currently ~3K tests, ~2K unique testers, ~120 browsers
      • help out by running the test!
    43. Measuring Performance
      • Episodes
      dev box synthetic testing bucket testing real user data Hammerhead
    44. Announcement 2: Hammerhead &quot;moving performance testing upstream&quot;
      • http://stevesouders.com/hammerhead/
      • Firebug extension
      • load M URLs N times, empty & primed cache
      • record average & median time
      • add'l features:
        • export data
        • load time measurement
        • modal cache clearing
      • combine with bandwidth throttler
    45. Takeaways
      • focus on the frontend
      • run YSlow: http://developer.yahoo.com/yslow
      • this year's focus: JavaScript
        • Split the Initial Payload
        • Load Scripts without Blocking
        • Don't Scatter Inline Scripts
      • speed matters
      • life's too short, write fast code
    46. Steve Souders [email_address] http://stevesouders.com/docs/widget-summit-2008.ppt

    + picardopicardo, 8 months ago

    custom

    440 views, 1 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 440
      • 440 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 10
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories