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

Workshop: Making Responsive Websites Fast

Workshop: Making Responsive Websites Fast

Summary of what we learned at the @LDNWebPerf workshop by https://twitter.com/guypod from Akamai, on how to make RWD sites fast!

(Used for an internal presentation)

Matt Bailey

May 20, 2015
Tweet

More Decks by Matt Bailey

Other Decks in Technology

Transcript

  1. Making Responsive
    Websites Fast

    View Slide

  2. What We Learned At
    The Akamai Workshop

    View Slide

  3. Setting The Scene

    View Slide

  4. • Mobile is big (1/3 of all traffic)!
    • Original approach - do nothing
    • Then, dedicated domains (eg. m.domain.com)
    • Now, Responsive Web Design
    The Mobile Web

    View Slide

  5. Responsive Web Design
    • Google recommends it
    • Adoption is fast on the increase
    • Challenge:
    • Different devices, same download
    • More bytes-per-pixel on smaller screens

    View Slide

  6. RWD Problems
    • Very few RWD sites optimise for performance
    • RWD sites generally heavier than mdot sites
    • RWD sites generally heavier to process than mdot sites
    • Example:
    • Old CNN site - Adaptive mdot, 571KB, 15s
    • New CNN site - RWD, 2.9MB, 41.9s
    • Load time matters!

    View Slide

  7. Problem: Over
    Downloading

    View Slide

  8. Problem: Over Downloading
    • Download and Shrink - the same image is used
    on all devices and just shrunk for smaller
    screens

    View Slide

  9. Solution: Responsive
    Images
    • ‘srcset’ - suggests to the browser which
    images to use
    • element - forces the browser to use
    certain images (art direction)
    • Browser support is good, but Polyfills are
    available for older browsers

    View Slide

  10. Problem: Download
    And Hide

    View Slide

  11. Problem: Download And
    Hide
    • Often images are hidden on ‘mobile’ views
    • The problem is that the browser still has to
    download them

    View Slide

  12. Solution: Conditional
    Loading (Client-Side)
    • Use placeholders (1px.gif), then swap the ‘src’ if
    the image is not set to ‘display: none;’
    • Or check for screen size, orientation changes
    etc.
    • You can also use the element to
    achieve a similar effect

    View Slide

  13. Problem: Over
    Downloading CSS

    View Slide

  14. Problem: Over Downloading
    CSS
    • Most sites have just one CSS file
    • Fewer requests, but wasteful bytes

    View Slide

  15. Solution: Conditional loading
    • You could have one file for each ‘breakpoint’
    • Conditionally load each file using media queries
    • All files are still downloaded, but deferred so
    not render blocking
    • or JavaScript (async)
    • Design mobile first

    View Slide

  16. Solution: Critical Rendering
    Path
    • Inline critical CSS in the head
    • Load non-priority CSS asynchronously
    • Without the CSSOM first paint is blocked

    View Slide

  17. REsponsive + Server
    Side

    View Slide

  18. REsponsive + Server Side
    (RESS)
    • Server conditionally assembles design response
    • Doesn’t replace RWD
    • Tuned for families families of devices (http://
    web.wurfl.io/)
    • Use cookies, get user’s device data, include/ignore
    blocks
    • Can’t add a cookie using JavaScript because it won’t
    be set on first view

    View Slide

  19. RESS With EDC

    View Slide

  20. RESS With Akamai Edge
    Device Characterisation (EDC)
    • Uses smarter device matching and smarter
    routing

    View Slide

  21. RESS With ESI

    View Slide

  22. RESS With Edge Side
    Includes (ESI)
    • Another form of conditional loading
    • Benefit: Can be placed directly in templates
    (looks like XML)
    • Works with EDC, eg. detect user’s screen width,
    then conditionally load block
    • Other providers offer (limited) ESI support, eg.
    Varnish

    View Slide

  23. Problem: Image File
    Sizes

    View Slide

  24. Problem: Image File Sizes
    • A LOT of image variants are required:
    • Thousands of products
    • Multiple images per product
    • Multiple breakpoints
    • Standard def and High def (Retina)
    • Versions optimised for browser type
    • Versions optimised for poor network
    • = LOTS of images to manage!
    • Image transcoding takes time (especially on the first-run)

    View Slide

  25. Solution: Better file formats
    • JPEGXR (IE)
    • WebP (Chrome, Android, Opera)
    • JPEG2000 (iOS, Safari)
    • JPEGXR and WebP can save over 30%
    compared to a standard JPEG

    View Slide

  26. • Akamai Image Manager for delivery-time
    selection
    • Use ‘srcset’ to load the right sized images
    • Use to load the right image format
    • Akamai Image Manager can also adjust image
    compression based on network performance

    View Slide

  27. Problem: Third-Party
    Scripts

    View Slide

  28. Problem: Third-Party Scripts
    • On the increase
    • Can pose a risk: SPOF (Single Point Of Failure)

    View Slide

  29. Solution: Async
    • Always load third-party scripts asynchronously

    View Slide

  30. Problem: Too Many
    Images

    View Slide

  31. Problem: Too Many Images
    • Often most images are ‘below the fold’
    • Especially on mobile

    View Slide

  32. Solution: Lazy Loading
    • Use JavaScript to load images on-demand

    View Slide

  33. You can be
    Responsive and fast!

    View Slide

  34. Thank you

    View Slide