Responsive Responsive Design at Peachpit Presents

A9a379f2e92c7ded4564190c5b286b78?s=47 Tim Kadlec
January 16, 2014

Responsive Responsive Design at Peachpit Presents

Presented for Peachpit Presents on January 16, 2014

A9a379f2e92c7ded4564190c5b286b78?s=128

Tim Kadlec

January 16, 2014
Tweet

Transcript

  1. Responsive Responsive Design Building sites that are flexible and fast

    Peachpit Presents | January 16, 2014
  2. None
  3. 20% in 5 days

  4. 15% in 24 hours

  5. 18% in 24 hours

  6. Most popular in 3 days

  7. 6 months. 681,900 Android devices. . . . . .

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . source: http://opensignal.com/reports/fragmentation.php
  8. Source: http://stephanierieger.com/the-trouble-with-android/

  9. None
  10. “I want the entire smartphone, the entire internet, on my

    wrist.”
  11. None
  12. None
  13. None
  14. None
  15. None
  16. @media [not|only] type [and] (expression) { ... }

  17. @media only screen and (min-width: 400px) { ... }

  18. None
  19. None
  20. None
  21. — Ethan Marcotte Now more than ever, we’re designing work

    meant to be viewed along a gradient of different experiences. Responsive web design offers us a way forward, finally allowing us to “design for the ebb and flow of things. http://alistapart.com/article/responsive-web-design
  22. None
  23. None
  24. None
  25. None
  26. — John Allsopp The control which designers know in the

    print medium, and often desire in the web medium, is simply a function of the limitation of the printed page. We should embrace the fact that the web doesn’t have the same constraints, and design for this flexibility. http://alistapart.com/article/dao
  27. More than layout

  28. Too good a job?

  29. — Ethan Marcotte Now more than ever, we’re designing work

    meant to be viewed along a gradient of different experiences. Responsive web design offers us a way forward, finally allowing us to “design for the ebb and flow of things. gradient of different experiences http://alistapart.com/article/responsive-web-design
  30. — Ethan Marcotte Now more than ever, we’re designing work

    meant to be viewed along a gradient of different experiences. Responsive web design offers us a way forward, finally allowing us to “design for the ebb and flow of things. gradient of different experiences http://alistapart.com/article/responsive-web-design
  31. — Stephanie Rieger Shoot me now…responsive design has seemingly become

    confused with an opportunity to reduce performance rather than improve it. https://twitter.com/stephanierieger/status/245240465572642816
  32. None
  33. 74 requests, 1511kb 114 requests, 1200kb 99 requests, 1298kb 105

    requests, 5942kb
  34. http://www.guypo.com/uncategorized/real-world-rwd-performance-take-2/ 72% 22% 6% Much Smaller Slightly Smaller Same Size

  35. http://www.guypo.com/uncategorized/real-world-rwd-performance-take-2/ 320x480 640x960 1024x768 1600x1200 0 200000 400000 600000 800000

    1000000 1200000 1400000
  36. http://www.guypo.com/uncategorized/real-world-rwd-performance-take-2/ 320x480 640x960 1024x768 1600x1200 0 200000 400000 600000 800000

    1000000 1200000 1400000
  37. Revenue

  38. Revenue Traffic Conversions Satisfaction Page views

  39. 71% as quickly or faster http://www.gomez.com/resources/whitepapers/survey-report-what-users-want-from-mobile

  40. Performance is a fundamental component of User Experience

  41. RWD is bad for performance!

  42. None
  43. Blame the implementation, not the technique.

  44. January 2012: 814.68kb January 2013: 1062.63kb http://www.stevesouders.com/blog/2013/04/05/page-weight-grows-24-year-over-year-not-44/

  45. 30%

  46. Performance needs to matter because it matters to users A

    culture of performance
  47. — A friend I doubt anyone really wants to release

    a site that doesn't perform well, it's just a product of not being afforded the luxury of time and top-down pressure.
  48. Set a performance budget

  49. Must be usable in <= 10s 65kB - 100kB

  50. 1. Optimize

  51. 1. Optimize 2. Remove

  52. 1. Optimize 2. Remove 3. Don’t Add

  53. Channel your inner performance masochist Embrace the pain

  54. Get real, early

  55. — Brad Frost You can’t mock-up performance in Photoshop.

  56. — Brad Frost You can’t mock-up performance in Photoshop.

  57. Or: Why I cry myself to sleep at night Responsive

    Images
  58. Compress any and all images Trim the fat

  59. None
  60. Savings after compression 244.4 KB

  61. None
  62. Don’t download things you don’t need Show not, waste note

  63. display:none is useless

  64. <div id="test1"> <img src="images/test1.png" alt="" /> </div> @media all and

    (max-width: 600px) { #test1 { display:none; } }
  65. Everybody loads it anyway

  66. <img class="lazyImg 4x3" data-include-size="medium" data-replace-src="/img/cat-in-hat.jpg" src="/img/4x3.png" />

  67. for (var i = lazy.length - 1; i >= 0;

    i--) { ! var includeSize = lazy[i].getAttribute('data-include-size'); ! ! ! ! ! if (!includeSize) { ! ! return; ! } ! if (includeSize[j].trim() == MQ) { ! ! lazy.length[i].src = lazy.length[i].getAttribute('data- replace-src'); ! ! return; ! } }
  68. None
  69. <div class="delayed-image-load" data-src="http://ichef.bbci.co.uk/news/200/ media/images/64664000/jpg/ 64664041_016703869.jpg" data-width="521" data-height="293"></div>

  70. <div class="delayed-image-load" data-src="http://ichef.bbci.co.uk/news/200/ media/images/64664000/jpg/ 64664041_016703869.jpg" data-width="521" data-height="293"></div>

  71. <div class="delayed-image-load" data-src="http://ichef.bbci.co.uk/news/200/ media/images/64664000/jpg/ 64664041_016703869.jpg" data-width="521" data-height="293"></div>

  72. <div class="delayed-image-load" data-src="http://ichef.bbci.co.uk/news/200/ media/images/64664000/jpg/ 64664041_016703869.jpg" data-width="521" data-height="293"></div>

  73. Make sure things are the right size and resolution Appropriate

    images
  74. 72%

  75. 255 values for red 255 values for green 255 values

    for blue 255 values for alpha
  76. 600px

  77. 550px

  78. (600 x 600) - (550 x 550) 57,500 pixels

  79. None
  80. <span data-picture data-alt="A giant stone face at The Bayon temple

    in Angkor Thom, Cambodia"> <span data-src="small.jpg"></span> <span data-src="medium.jpg" data-media="(min-width: 400px)"></span> <span data-src="large.jpg" data-media="(min-width: 800px)"></span> <span data-src="extralarge.jpg" data-media="(min-width: 1000px)"></span> <!-- Fallback content for non-JS browsers. Same img src as the initial, unqualified source element. --> <noscript> <img src="external/imgs/small.jpg" alt="A giant stone face at The Bayon temple in Angkor Thom, Cambodia"> </noscript> </span>
  81. L.Q.I.P Low Quality Image Placeholders

  82. <img src="dummy.400x300.jpg" alt="Responsive Image" data-fullsrc="dummy.800x600.jpg" />

  83. Compressive Images AKA Black Magic

  84. http://blog.netvlies.nl/design-interactie/retina-revolution/

  85. SVG

  86. <img src="image.svg" onerror="this.onerror=null; this.src='image.png'">

  87. .main-header { background: url(logo.svg) no-repeat top left; background-size: contain; }

    .no-svg .main-header { background-image: url(logo.png); }
  88. 1. Analyze

  89. 1. Analyze 2. Big images first

  90. (600 x 600) - (550 x 550) 57,500 pixels

  91. (200 x 200) - (150 x 150) 17,500 pixels

  92. 57,500 / 17,500 = 3.2x

  93. 1. Analyze 2. Big images first 3. Know the trade-offs

  94. Actually, not so sucky Background images

  95. <div id="test3"> <div></div> </div> #test3 div { background-image:url('images/test3.png'); width:200px; height:75px;

    } @media all and (max-width: 600px) { #test3 { display:none; } }
  96. <div id="test5"></div> @media all and (min-width: 601px) { #test5 {

    background-image:url('images/test5-desktop.png'); width:200px; height:75px; } } @media all and (max-width: 600px) { #test5 { background-image:url('images/test5-mobile.png'); width:200px; height:75px; } }
  97. Load only what you need, when you need it Conditional

    loading
  98. 1. Content https://speakerdeck.com/andyhume/anatomy-of-a-responsive-page-load-whiskyweb-ii

  99. 1. Content https://speakerdeck.com/andyhume/anatomy-of-a-responsive-page-load-whiskyweb-ii 2. Enhancements

  100. 1. Content https://speakerdeck.com/andyhume/anatomy-of-a-responsive-page-load-whiskyweb-ii 2. Enhancements 3. Leftovers

  101. Cutting the mustard

  102. if ('querySelector' in document ! && 'localStorage' in window !

    && 'addEventListener' in window) { ... }
  103. http://bit.ly/RSrWVI

  104. http://bit.ly/RSrWVI

  105. http://bit.ly/RSrWVI

  106. globe.enhanced = ( ! respond.mediaQueriesSupported ! || globe.browser.ie6 ! ||

    globe.browser.ie7 ! || globe.browser.ie8 )
  107. None
  108. None
  109. None
  110. <h2> <a data-target="reviews" href="reviews.html">Reviews</a> </h2>

  111. anchorInclude : function ( elem ) { var url =

    elem.getAttribute('href'); var target = document.getElementById( elem.getAttribute('data-target') ); reqwest(url, function (resp) { target.innerHTML = resp; }); }
  112. <a href="..." data-replace="articles/latest/fragment">Latest Articles</a> <a href="..." data-before="articles/latest/fragment">Latest Articles</a> <a href="..."

    data-after="articles/latest/fragment">Latest Articles</a> <a href="..." data-append="articles/latest/fragment">Latest Articles</a>
  113. $("[data-append],[data-replace],[data-after], [data-before]").ajaxInclude();

  114. No AJAX, no problem

  115. <div data-lazy-content="more_puppies" aria- live="polite"> <!-- <p>You clicked for more puppies!

    Here you go:</p> <img src="puppy.jpg" alt="Lazy loaded puppy image" /> --> </div>
  116. var toShow = document.querySelectorAll('[data-lazy-content=' + item.getAttribute('[data-lazy-reveal]') + ']'; for (var

    j = toShow.length - 1; j >= 0; j--) { ! var children = toShow[j].childNodes; ! for (var k = children.length - 1; k >= 0; k--) { ! ! var child = children[k]; ! ! if (child.nodeType === 8) { ! ! ! //it's a comment ! ! ! toShow[j].innerHTML = child.nodeValue; ! ! ! break; ! ! } ! } }
  117. What about CSS?

  118. Embedded a { ! text-decoration: none; } @media screen and

    (min-width: 1300px) { ! a { ! ! text-decoration: underline; ! } }
  119. External <link href="style.css" media="only screen and (min-width: 1300px)" />

  120. All styles downloaded

  121. http://scottjehl.github.com/CSS-Download-Tests/

  122. <link rel="stylesheet" href="style.css" media="seriously please do not download this what

    is the matter with you why won’t you listen" />
  123. None
  124. Chrome 26 Safari 6.0.2 iOS Safari 6.1 Android 4.2.1 Android

    4.2.1 Chrome 18 Android 4.2.1 Chrome 18 Android 4.2.1 Opera Mini Yay!
  125. Internet Explorer 10 Internet Explorer 9 Internet Explorer 8 Firefox

    20 Opera 12.15 Android 4.2.1 Opera Mobile Nooooo!
  126. https://twitter.com/ppk/status/249100988693241856

  127. jQuery = 200-300ms based on 1.8.0 http://jsperf.com/zepto-jq-eval

  128. Up to 8s!

  129. Custom jQuery builds

  130. Everything has a trade-off

  131. None
  132. What value does this provide?

  133. Don’t worry about JS size. Just include one less image.

  134. Don’t worry about JS size and Just include one less

    image.
  135. Time to move beyond visual aesthetics

  136. This may not be easy...

  137. ...but man is it fun!

  138. thank you! @tkadlec timkadlec.com TIM KADLEC

  139. implementingresponsivedesign.com peachpit.com/deals