Speed is Essential for a
Great Web Experience

@andydavies




Port 80 (#p80N)
May 2012
                           http://www.flickr.com/photos/44442915@N00/5214810596
But sometimes other concerns take priority...




                            http://www.flickr.com/photos/randomidea/247994072
“Are we there yet?”


                      http://www.flickr.com/photos/sharynmorrow/643126727
Our perception of response time

  Instant

       Seamless                                                   Yawn!




100ms 1s                                                         10s




                  Response Time in Man-computer Conversational Transactions
                                                     Robert B. Miller, 1968
Our perception of response time

  Instant

       Seamless                                                           Yawn!




100ms 1s                                                                 10s

            3s - Recommended         7s - Fortune 500
                 Load Time            Average (2010)


                          Response Time in Man-computer Conversational Transactions
                                                             Robert B. Miller, 1968
“50% more concentration when using
       badly performing web sites”
                                               Foviance

          http://www.flickr.com/photos/yourdon/3366991042
Effect of delay on abandonment rate...




      Abandonment rate over 200+ sites / 177+ million page views over 2 weeks - http://www.measureworks.nl / Gomez
Google conducted an experiment




 +400ms                     -0.6%
Bing did some experiments too




     +1s
                          $/    - 2.8%
                                         +
Shopzilla cut page load time by 5 seconds!



  +12%          +25%                                -50%

   $$$

                       http://velocityconf.com/velocity2009/public/schedule/detail/7709
Measuring page load time...
Measure Real Users’ Experience

                         27%

                                                                              24%
Visitors (%)




                               13%



                    8%               8%
               6%                              6%

                                                               3%   3%
                                                          2%
                                                                         1%

               1    2    3     4     5         6          7    8    9    10   > 10
                                          Load Time (s)
Measuring Real Users - Google Analytics




Relies on Navigation Timing API, can add extra timing calls to page
Measuring Real Users - Torbit Insight
Measuring Real Users - Torbit Insight




                    (Check out at Log Normal too)
Measuring Real Users - New Relic
webpagetest.org
Waterfall for bbc.co.uk/news
www.blaze.io/mobile
Bigger, Faster Servers?


                          http://www.flickr.com/photos/br1dotcom/4297736794
80% plus of page load time is on front-end

                                                                 Backend
 news.bbc.co.uk
                                                                 Frontend
      ebay.co.uk

debenhams.co.uk

   direct.gov.uk

   amazon.co.uk

  mumsnet.com

  guardian.co.uk

                   0   1.25          2.5                3.75                5

                              Measured on residential ADSL line using Chrome 19
Fix slow server responses first




    4 seconds!
Bandwidth (often) isn’t the bottleneck



2.0

1.5

1.0

0.5


  0s                   5s                                       10s

                 news.bbc.co.uk tested via webpagetest.org throttled at 1.5Mbps
                                     (bursts over 1.5Mbps are artifact of testing)
Minimum round trips to download a file

                                                             (TCP Segments)
285kB


214kB


143kB


 71kB

 Size
        1   2    3    4   5   6     7      8      9     10      11

        Round Trips               TCP and the Lower Bound of Web Performance
                                                                  John Rauser
Speeding Things Up - The Basics


                              CSS at top

                              Compress
                              Consilidate
                              Minify
                              Reduce Requests
                              Cache Forever

                                  JS at bottom
Proportion of URLs that can be compressed




          ☺
                                          ☹
            http://zoompf.com/blog/2012/05/http-compression-use-by-alexa-top-1000
What’s the web made of?

                                                         Images
                                                         Scripts
                                                         Stylesheets
                                                         HTML
                                                         Flash
                                                         Other




                   Composition of ‘average’ web page via httparchive.org
Bitmapped Images




    JPEG                            PNG                           GIF


       Optimise, Optimise, Optimise!
           (jpegmini, pngmini, Smush.it, ImageOptim, Gifsicle etc.)
CSS Sprites




                    +
       background-position: -408px 0;
       width: 128px;
       height: 128px;

                    =
Data-URIs


<img width="128" height="128"
src="data:image/PNG;base64,
iVBORw0KGgoAAAANSUhEUgAAAIAA

            ...                          =
GAA39eV7u4AAAAAElFTkSuQ" />




            Should be served with GZIP
New Devices, New Challenges...




                2 x Resolution = 4 x Pixels!

                           http://www.flickr.com/photos/roopaw/6985954465
Look Ma, No Images!


border-radius: 20px;




background: linear-gradient(left, #f06, #ff0);




   Watch mobile performance. Remember vendor prefixes!
Vector Graphics FTW?




          SVG: 12 KB vs PNG: 86KB
What about icon / pictogram fonts?



                                  &#x2605; ★
                                  &#x2606; ☆
                                  &#x2665; ♥
                                  &#x2601; ☁

       Heydings by Heydon Works   “Bog Standard Font”
display:none - still downloads images



     “‪#p80n‬ you do get adverts on the smashingmag
       site on smaller viewports. They just hideously
       display:none; so you still down load them :-/”


                                         @sturobson
                                     ‬
Don’t forget about favicon.ico


        1.4 seconds for favicon!
Don’t forget about favicon.ico


           1.4 seconds for favicon!




 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
 lang="en">
 <head>
     <meta http-equiv="Content-Type" content="text/html;
 charset=utf-8" />
Don’t block the browser...




                             http://www.flickr.com/photos/barteko/6128499314
news.bbcimg.co.uk
                         static.bbc.co.uk




Browsers can download resources in parallel
But Sometimes... The Waterfall of Doom!




                  2 seconds! (nearly)
Social buttons break...




                          http://bit.ly/yRjX63
Social buttons break...




                          http://bit.ly/yRjX63
Load Third Party scripts asynchronously


 <script type="text/javascript">
   function()
     var js = document.createElement('script');
     js.async = true;
     js.src = 'myscript.js'
     var e = document.getElementsByTagName('script')[0];
     e.parentNode.insertBefore(js, first);
   })();
 </script>
Argh... My brain hurts!
                     http://www.flickr.com/photos/corneveaux/3248566797
Don’t have to do it all by hand
            http://www.flickr.com/photos/simeon_barkas/2557059247
Performance isn’t just for Christmas

                     Measure




          Optimise             Analyse
http://www.flickr.com/photos/jurvetson/6212582593
@andydavies
         andy@asteno.com
http://www.slideshare.net/andydavies




                       http://www.flickr.com/photos/auntiep/5024494612
Credits


All photographs copyright original owners on flickr.com

Following pictograms courtesy of The Noun Project

Speed is Essential for a Great Web Experience

  • 1.
    Speed is Essentialfor a Great Web Experience @andydavies Port 80 (#p80N) May 2012 http://www.flickr.com/photos/44442915@N00/5214810596
  • 2.
    But sometimes otherconcerns take priority... http://www.flickr.com/photos/randomidea/247994072
  • 3.
    “Are we thereyet?” http://www.flickr.com/photos/sharynmorrow/643126727
  • 4.
    Our perception ofresponse time Instant Seamless Yawn! 100ms 1s 10s Response Time in Man-computer Conversational Transactions Robert B. Miller, 1968
  • 5.
    Our perception ofresponse time Instant Seamless Yawn! 100ms 1s 10s 3s - Recommended 7s - Fortune 500 Load Time Average (2010) Response Time in Man-computer Conversational Transactions Robert B. Miller, 1968
  • 6.
    “50% more concentrationwhen using badly performing web sites” Foviance http://www.flickr.com/photos/yourdon/3366991042
  • 7.
    Effect of delayon abandonment rate... Abandonment rate over 200+ sites / 177+ million page views over 2 weeks - http://www.measureworks.nl / Gomez
  • 8.
    Google conducted anexperiment +400ms -0.6%
  • 9.
    Bing did someexperiments too +1s $/ - 2.8% +
  • 10.
    Shopzilla cut pageload time by 5 seconds! +12% +25% -50% $$$ http://velocityconf.com/velocity2009/public/schedule/detail/7709
  • 11.
  • 12.
    Measure Real Users’Experience 27% 24% Visitors (%) 13% 8% 8% 6% 6% 3% 3% 2% 1% 1 2 3 4 5 6 7 8 9 10 > 10 Load Time (s)
  • 13.
    Measuring Real Users- Google Analytics Relies on Navigation Timing API, can add extra timing calls to page
  • 14.
    Measuring Real Users- Torbit Insight
  • 15.
    Measuring Real Users- Torbit Insight (Check out at Log Normal too)
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
    Bigger, Faster Servers? http://www.flickr.com/photos/br1dotcom/4297736794
  • 21.
    80% plus ofpage load time is on front-end Backend news.bbc.co.uk Frontend ebay.co.uk debenhams.co.uk direct.gov.uk amazon.co.uk mumsnet.com guardian.co.uk 0 1.25 2.5 3.75 5 Measured on residential ADSL line using Chrome 19
  • 22.
    Fix slow serverresponses first 4 seconds!
  • 23.
    Bandwidth (often) isn’tthe bottleneck 2.0 1.5 1.0 0.5 0s 5s 10s news.bbc.co.uk tested via webpagetest.org throttled at 1.5Mbps (bursts over 1.5Mbps are artifact of testing)
  • 24.
    Minimum round tripsto download a file (TCP Segments) 285kB 214kB 143kB 71kB Size 1 2 3 4 5 6 7 8 9 10 11 Round Trips TCP and the Lower Bound of Web Performance John Rauser
  • 25.
    Speeding Things Up- The Basics CSS at top Compress Consilidate Minify Reduce Requests Cache Forever JS at bottom
  • 26.
    Proportion of URLsthat can be compressed ☺ ☹ http://zoompf.com/blog/2012/05/http-compression-use-by-alexa-top-1000
  • 27.
    What’s the webmade of? Images Scripts Stylesheets HTML Flash Other Composition of ‘average’ web page via httparchive.org
  • 28.
    Bitmapped Images JPEG PNG GIF Optimise, Optimise, Optimise! (jpegmini, pngmini, Smush.it, ImageOptim, Gifsicle etc.)
  • 29.
    CSS Sprites + background-position: -408px 0; width: 128px; height: 128px; =
  • 30.
  • 31.
    New Devices, NewChallenges... 2 x Resolution = 4 x Pixels! http://www.flickr.com/photos/roopaw/6985954465
  • 32.
    Look Ma, NoImages! border-radius: 20px; background: linear-gradient(left, #f06, #ff0); Watch mobile performance. Remember vendor prefixes!
  • 33.
    Vector Graphics FTW? SVG: 12 KB vs PNG: 86KB
  • 34.
    What about icon/ pictogram fonts? &#x2605; ★ &#x2606; ☆ &#x2665; ♥ &#x2601; ☁ Heydings by Heydon Works “Bog Standard Font”
  • 35.
    display:none - stilldownloads images “‪#p80n‬ you do get adverts on the smashingmag site on smaller viewports. They just hideously display:none; so you still down load them :-/” @sturobson ‬
  • 36.
    Don’t forget aboutfavicon.ico 1.4 seconds for favicon!
  • 37.
    Don’t forget aboutfavicon.ico 1.4 seconds for favicon! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  • 38.
    Don’t block thebrowser... http://www.flickr.com/photos/barteko/6128499314
  • 39.
    news.bbcimg.co.uk static.bbc.co.uk Browsers can download resources in parallel
  • 40.
    But Sometimes... TheWaterfall of Doom! 2 seconds! (nearly)
  • 41.
    Social buttons break... http://bit.ly/yRjX63
  • 42.
    Social buttons break... http://bit.ly/yRjX63
  • 43.
    Load Third Partyscripts asynchronously <script type="text/javascript"> function() var js = document.createElement('script'); js.async = true; js.src = 'myscript.js' var e = document.getElementsByTagName('script')[0]; e.parentNode.insertBefore(js, first); })(); </script>
  • 44.
    Argh... My brainhurts! http://www.flickr.com/photos/corneveaux/3248566797
  • 45.
    Don’t have todo it all by hand http://www.flickr.com/photos/simeon_barkas/2557059247
  • 46.
    Performance isn’t justfor Christmas Measure Optimise Analyse
  • 47.
  • 48.
    @andydavies andy@asteno.com http://www.slideshare.net/andydavies http://www.flickr.com/photos/auntiep/5024494612
  • 49.
    Credits All photographs copyrightoriginal owners on flickr.com Following pictograms courtesy of The Noun Project

Editor's Notes

  • #2 Andy Davies\n\nSpecialise in making web sites faster, more reliable and helping them scale as they grow\n\nSlides complete will go on Slideshare in the next day or so\n\nIf anyone has any questions or comments feel free to send me a tweet...\n\n\n
  • #3 \n
  • #4 \n
  • #5 How we perceive response times\n\nStrangeloop Networks research into load times of Alexia Top 2000 ecommerce sites \n - Average page load time 11.21s\n - Best 2.2x, worst 40.2s!\n - Only 13 loaded in less that 5s\n\nOur perception of load time is off:\n- Our expectation is faster\n- Perceive load time as 15% slower than reality\n- Recount experience as 35% slower\nStoyan Stefanov - Psychology of Performance\n
  • #6 Retail task - find and buy a laptop on a leading e-commerce site\nInsurance task - find and buy personal travel insurance on an insurance website. \nEEG &amp; EOG, camera\n
  • #7 \n\nAlso people&amp;#x2019;s perception of time is faulty... (Stoyan Stefanov, Psychology of Performance)\n - Average person perceives page takes 15% longer to load that reality\n - Will recount it as 35% longer when talking to others\n\n
  • #8 Amazon - 100 ms delay - sales down 1%\n
  • #9 \n
  • #10 ShopzillaUptime 99.51% &gt; 99.97\n\nMozillareduced load time by 2.2 secs = 60 million extra downloads / year\n\nYahootraffic went up 9% for every 400ms improvement\n\nNetflix: Reduced outbound bandwidth by 43%\n\nKerboodle: Reduced hosting costs by over &amp;#x20AC;30,000 per year\n\n
  • #11 How many have websites?\n\nHow many think theirs is fast?\n\nHow many measure?\n
  • #12 We are not real users...\n\nActual page load times from a real site, note huge peak of over 10 seconds\n\nMany external factors can affect page load time:\n\n- Browser\n- How they are connected ADSL / mobile / public WiFi\n- Bandwidth\n- Latency\n- Anti-virus\n- Network kit\n- etc\n\nThese factors are beyond our control but to get a true picture of page load times we must measure them in the visitors browser.\n
  • #13 Navigation Timing API \n - Firefox 7+, IE9+, Chrome 6+, Chrome on ICS\n - NO SAFARI - OS X or iOS!!!\n\nCan script to add extra timings\n\nLow sample rate\n\nAverages!!!\n\nIncrease sample rate from 1% to 100% add:\n\n_gaq.push([&apos;_setSiteSpeedSampleRate&apos;, 100]);\n\nPage load time data collected by default since 16th Nov 2011\n\nGood description of how it works on StackOverflow\n\n
  • #14 \n
  • #15 \n
  • #16 \n
  • #17 \n
  • #18 \n
  • #19 \n
  • #20 Some server performance issues can be improved by throwing hardware at it e.g. faster processors, more RAM (Databases love RAM), faster disks.\n\nBut should still look at optimising the back-end as it&amp;#x2019;s an important part of the picture e.g. DB tuning, architectures, reverse proxies etc.\n\nEven without tuning the server can still improve page load times by &amp;#x201C;flushing early&amp;#x201D;\n\n
  • #21 Even higher on mobile\n
  • #22 \n
  • #23 Bursting over 1.5Mbps = Testing Artifact\n
  • #24 \n
  • #25 What about CDN?\nWhat about cheating on TCP slow-start\nLinux 2.6.39 increases initcwnd to 10\n
  • #26 16% vs 84% - might want to compare against the 1/3 vs 2/3 I generally see\nBased on 97,000 URLs from Alexa Top 1000\nAdd an arrow to red segment saying images...\n
  • #27 \n
  • #28 What about PNGs and transparency? - need to cover the issues\n
  • #29 Traditionally been a pain to create but tools are much better + cSS preprocessors\n
  • #30 \n
  • #31 \n
  • #32 plus more - shadows, text gradients, transforms etc.\n\nbox-shadow:3px 3px 5px 6px #ccc;\n\nMobile impications @brianleroux\n
  • #33 SVG - 40KB Uncompressed / 12KB Compressed\nPNG - 800x480 - 86KB optimised\n
  • #34 Scales as user alters text size\n
  • #35 \n
  • #36 \n
  • #37 \n
  • #38 \n
  • #39 \n
  • #40 What if they are slow? down? Or even blocked - country, corporate firewall etc.?\n\n21s before rendering starts when Twitter is down\n\n\n
  • #41 Don&amp;#x2019;t blindly add third party scripts to a site\n\nMany social sites now have async versions, use the latest snippet.\n\nAddThis doesn&amp;#x2019;t - don&amp;#x2019;t use it\n\nOpenDNS blocked Google&amp;#x2019;s jQuery CDN!\n\nh5bp includes html5shiv from googlecode - it&amp;#x2019;s only 1KB, quicker to load from own site\n
  • #42 \n
  • #43 Some things can be automated e.g. compression, minification, merging, image compression plus more sophisticated optimisations.\n\nFrom plugins for Wordpress and web servers, appliances that sit in front of your server farm through to cloud-based optimisation services.\n\nOther are a little more difficult e.g. flush early, improving backed performance, asynchronous loading scripts etc.\n\nAutomation products / tools...\n\nFramework support\n Asset pipeline (Rails)\n Resources plugin (Grails)\n Webassets (Python)\n Assetic (PHP)\n\nCMS plugins\n - W3 Total Cache for Wordpress\n\nServer plugins\n - mod_pagespeed (Apache)\n - reduce requests (IIS)\n - Aptimize (IIS) (&amp;#xA3;)\n - Webo (&amp;#xA3;)\n\nAppliances\n - Strangeloop (&amp;#xA3;)\n - Traditional ADCs do some of this e.g. compression\n\nCloud services\n - Strangeloop (&amp;#xA3;)\n - Torbit (&amp;#xA3;)\n - Blaze.io (&amp;#xA3;)\n - Yotta (&amp;#xA3;)\n - Google&amp;#x2019;s PageSpeed service\n
  • #44 \n
  • #45 \n
  • #46 \n
  • #47 \n