Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Optimizing for Mobile Performance

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Optimizing for Mobile Performance

Presented at the Rich Web Experience in Fort Lauderdale, FL on 12/1/11.

Avatar for Tim Kadlec

Tim Kadlec

December 01, 2011
Tweet

More Decks by Tim Kadlec

Other Decks in Programming

Transcript

  1. http://flic.kr/p/5DBgES Optimizing for Mobile Performance presented by Tim Kadlec at

    The Rich Web Experience 2011 in Fort Lauderdale, FL timkadlec.com @tkadlec
  2. Jeff Bezos (July 2010) In the last twelve months, customers

    around the world have ordered more than US $1 billion of products from Amazon using a mobile device. Source: http://bit.ly/oKcI3e
  3. 71% of mobile users expect websites to load as quickly,

    almost as quickly or faster on their mobile phone, compared to the computer they use at home Source: http://bit.ly/w2Dg3W
  4. <= 1 second 2 seconds 3 seconds 4 seconds 5

    seconds > 5 seconds 30% 14% 21% 24% 11% 18% 12% How quickly should a mobile site load? Source: http://bit.ly/tB9Q3T
  5. 25% 50% 75% 100% 2009 2011 20% 74% Percentage of

    people who will bounce after 5 seconds Source: http://bit.ly/viowVq
  6. Rollin Shelton Source: http://wapo.st/nXtqkd My default posture now, when wanting

    to check news sites, is to pretty much avoid The Post all together.
  7. -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px background-color: #0081db; background-image: -webkit-gradient(linear,

    left top, left bottom, from(#14a1f0), to (#0081db)); background-image: -webkit-linear-gradient(top, #14a1f0, #0081db); background-image: -moz-linear-gradient(top, #14a1f0, #0081db); background-image: -ms-linear-gradient(top, #14a1f0, #0081db); background-image: -o-linear-gradient(top, #14a1f0, #0081db); background-image: linear-gradient(top, #14a1f0, #0081db);
  8. They’re a little ugly... data:image/ png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAASCAMAAACQGyXoAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZ SBJbWFnZVJlYWR5ccllPAAAAUdQTFRFFxUOJiMMFBIOkYsCjIYDioQDGxkNk40CYVwHNDALgHoENTILHRoNJSIMb WgFnJYBnpcBJCEMiYMDKygMPzwKWlUHREAJSUUJlo8CgXsEkIoCGBYNmJECIh8NXFgHHx0NExEOp6AAcWwFjYcD RkMJcm0Fgn0EHRsNUEwIY14GpJ0AcGoFIiAMT0sITEgJKCUMHBoNpp8Al5ECjogCa2YGaWQGIB0Nd3IFmZMBFhMOJ yQMGhgNiIIDWVQHOjcKLSoLIyAMODQKKicMVVEIPToKd3EFQj4KenQEaGQGS0cJh4EDlY8CoJkBfHcEZWAGaGMG

    hX8DZ2IGo5wAi4UDopsBlY4CeHIFRUEJXFcHdG8FKSYMeHMEmpMBV1MISkYJfnkEf3oEc24FnZcBVFAIeXQEQ0AJNj MLmJIBYl0Hn5gBVlEIqKEAEhAOjBZoxgAAAG10Uk5T///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// AC221EsAAAEWSURBVHjabNHlVwMxDADw3u1kbGPK3NhwGe7uvuE+3En+/8/k2h6sQD70pf3l9aUNQ0Q9dj5/ WWjFv8EQI2kAaJvA/ 7WTcKr513kgL9UkTcpar9En6ljHttBVgBFL6D4VeiI8TUAL1+ljMAQugxOZopPne3MWqY4LMCoavuEKUY3yoRC8kJYL2 FNnXCtCwaZL/QBB0mvw3YZXuF6dSC4Z4ynqgHRwl7anTzNZ4jFojJzTVaB96y4Fwx925iKp6Doy +XpzL354tvauaMJVKzRH66eCnqzULh8MYP+BguEm/hu46H2EOOKkgvYr/8nZ8tHbA9XhZiM+L8kpaJrOry/uuFRK +78n+DPNjVo1at4Hu2PuyZcAAwA2KbSDyyYFcAAAAABJRU5ErkJggg==
  9. Use a script loader <script> $LAB .script("myScript.js") .script("bonusScript.js"); </script> http://labjs.com/

    <script> $script(“myScript.js”); $script(“bonusScript.js”); </script> http://dustindiaz.com/scriptjs
  10. Source: http://bit.ly/gpwaa Lazy-loading JS <html> ... <script id="lazy"> // Make

    sure you strip out (or replace) comment blocks in your JavaScript first. /* JavaScript of lazy module */ </script> <script> function lazyLoad() { var lazyElement = document.getElementById('lazy'); var lazyElementBody = lazyElement.innerHTML; var jsCode = stripOutCommentBlock(lazyElementBody); eval(jsCode); } </script> <div onclick=lazyLoad()> Lazy Load </div> </html>
  11. http://googlecode.blogspot.com/2009/09/gmail-for-mobile-html5-series-reducing.html 200k of JavaScript held within a block comment adds

    240ms during page load, whereas 200k of JavaScript that is parsed during page load added 2600 ms.
  12. Alex MacCaw http://alexmaccaw.co.uk/posts/async_ui ...interfaces should be completely non- blocking. Interactions

    should be resolved instantly; there should be no loading messages or spinners.
  13. CACHE MANIFEST # This manifest was created by confess.js, http://github.com/jamesgpearce/

    confess # # Time: Wed Apr 13 2011 15:40:27 GMT-0700 (PDT) # URL: http://functionsource.com # UA: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/533.3 (KHTML, like Gecko) PhantomJS/1.1.0 Safari/533.3 # # Any console output generated by this page or app is shown immediately below. You'll need to remove this to create a valid manifest syntax. # [Start of console output] # [End of console output] CACHE: /javascripts/lib/jquery.js /javascripts/lib/underscore.js /javascripts/lib/backbone.js ........ http://functionsource.com/images/icons/rss.png http://functionsource.com/images/icons/podcast.png http://functionsource.com/images/icons/firehose.png NETWORK: *
  14. Joshua Bixby Source: http://bit.ly/mXUvR7 It took our community almost ten

    years to generate meaningful data around regular web performance. We don’t have that luxury with the mobile internet.