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

Your Hero Images Need You! Save the Day with HT...

Your Hero Images Need You! Save the Day with HTTP2 Image Loading - 90min Workshop at Velocity Santa Clara 2016

Images are a crucial component of all websites. They evoke emotions and prompt actions. They also form 64% of website data and have the highest correlation to page-load time. While modern image compression techniques can alleviate some of the negative impact of image loading, key web performance metrics such as the Speed Index and Time to Interact suffer due to our need for images.

HTTP/2 puts a powerful tool at our disposal to address these issues for image loading. Tobias Baldauf explains how to use HTTP/2’s superpowers to optimize image delivery, thereby increasing the perceived performance of your page, reducing load times, and driving conversions. Tobias explores the details of HTTP/2’s multiplexing in depth and demonstrates how to leverage it to address image loading. You’ll learn how to take granular control of the encoding process for progressive or interlaced images to improve both performance and users’ emotional response time to page visuals.

Tobias Baldauf

June 21, 2016
Tweet

More Decks by Tobias Baldauf

Other Decks in Technology

Transcript

  1. // Print quality of JPEG image identify -format '%Q' input.jpg

    // Create smaller JPEG with same quality as input image mozjpeg -quality 86 -outfile output_mozjpeg.jpg input.jpg // Measure dissimilarity using DSSIM and intermediate PNGs dssim input.png output_mozjpeg.png // Auto-Tune best JPEG compression parameters using cjpeg-dssim cjpeg-dssim mozjpeg input.jpg // Print Interlace status of JPEG to see if it's progressively encoded identify -verbose input.jpg | grep Interlace 29 / 103
  2. Default Scan Levels Thanks to Frédéric Kayser for creating 'jsk':

    http://encode.ru/threads/1800-JSK-JPEG-Scan-Killer-progressive-JPEG-explained-in-slowmo 33 / 103
  3. // Create a progressively encoded JPEG with default scan layers

    using mozjpeg mozjpeg -outfile output_mozjpeg_default_scans.jpg input.jpg // Split a progressive JPEG apart to see its scan layers jsk output_mozjpeg_default_scans.jpg // Create a progressively encoded JPEG with custom scan layers mozjpeg -scans scans-custom.txt -outfile output_mozjpeg_custom_scans.jpg input.jpg 41 / 103
  4. Site A displays 7.4x faster than Site B more info

    at https://sites.google.com/a/webpagetest.org/docs/using-webpagetest/metrics/speed-index 56 / 103
  5. // Optimal initcwnd formula (MBps * RTT) / 1500 BytesPerPackage

    = optimal initcwnd // Example for 6Mbps and 50ms RTT (considering that 1Mbps = 125Kbps): 6*125Kbps = 750Kbps // Let's assume 50ms RTT 750 * 0.050= 37.5 37.5 / 1500 Bytes Per Package = 0,025 => optimal initcwnd of 25 for a single connection as in HTTP2 73 / 103
  6. // Check current initcwnd settings on *nix ip route show

    // Change initcwnd setting for a network interface // Make sure that the IP address matches sudo ip route change default via 123.123.123.123 dev eth0 initcwnd 25 75 / 103
  7. We now know about Progressive JPEGs The benefits of HTTP2

    & its optimized delivery of Scan Layers 76 / 103
  8. John Melor (Google, SPDY, 2012): @15%: initial visuals @35%: good

    visuals thanks to John Melor for this fantastic research and thanks to Yoav Weiss & Andy Davies for publishing it in their slide decks! See https://yoavweiss.github.io/respimg-blinkon-presentation/#/71/2 78 / 103
  9. // Prioritize a progressive JPEG's metadata and scan levels //

    with minimal 'calm' => maximum priority <img src="img/jpeg_opJPEG/tba/00001.jpg?bil=0!0"> // Create a cumulative cascade of 'calm' // for a progressive JPEG's metadata and scan levels // Each new value is added to the sum, lowering priority per scan layer <img src="img/jpeg_opJPEG/tba/00001.jpg?bil=0!100,50,20"> 92 / 103