Delivering Beautiful and Fast
Images and Video
Doug Sillars
@DougSillars
MCRFred
September 20, 2018
Contact Me:
@DougSillars
Doug.Sillars@gmail.com
www.dougsillars.com
Doug Sillars
https://www.slideshare.net/dougsillars/
Freelance Developer Relations
Performance Audits: Web/Native
Workshops:
Performance/Images/Video
0.5
0.6
0.7
0.8
0.9
Standing in Line Standing on the
edge of a virtual
cliff
Experiencing
Mobile Delays
Solving a Math
Problem
https://www.ericsson.com/res/docs/2016/mobility-report/emr-feb-2016-the-stress-of-steaming-delays.pdf
Stress
Large Downloads Induce Delays in Rendering
3s: 53% of Users Abandon Mobile Sites
500ms: 26% Frustration
8% Engagement
100ms: 1% Revenue Walmart & Amazon (Desktop 2001)
4% Mobile Users Throw Their Phones
https://www.doubleclickbygoogle.com/articles/mobile-speed-matters
http://bit.ly/mobileWebStress
http://www.globaldots.com/how-website-speed-affects-conversion-rates/
https://www.mobilejoomla.com/blog/172-responsive-design-vs-server-side-solutions-infographic.html
Images & Video make up 75% of Web Content
HTTPArchive mobile websites 15/02/18
4 Simple Image Optimizations
4 Simple Image Optimizations
1. Quality
2. Format
3. Sizing
4. Lazy Loading
4 Simple Image Optimizations
1. Quality
2. Format
3. Sizing
4. Lazy Loading
4 Simple Image Optimizations
Httparchive.org Webpagetest.org
4 Simple Image Optimizations
1. Quality
2. Format
3. Sizing
4. Lazy Loading
Image Quality
Lossy
Image size is reduced by
removing pixel information
https://developers.google.com/speed/docs/insights/OptimizeImages
Image Quality
magick -quality 85 riga.jpg riga85.jpg
http://res.cloudinary.com/dougsillars/image/upload/q_85/v1520504964/IMG_20180301_114117_tzasan.jpg
Lighthouse:
Recommends 85% quality on all images
https://developers.google.com/speed/docs/insights/OptimizeImages
Image Quality Use “In The Wild”
500,000 mobile sites
Analyzed 3/15/18
Image Quality Use “In The Wild”
Median Savings (50th percentile):
• 2.83 seconds faster page load
• 419KB less data
File Format: Web
<picture>
<source width = "100%" type="image/webp" srcset=”riga.webp">
<img width = "100%" src=”riga_cjpeg_dssim.jpg"
alt=”Riga, Latvia">
</picture>
100%
1.8 MB
http://res.cloudinary.com/dougsillars/image/upload/v1537006839/20180914_142934_v7wn0v.jpg
85%
983 KB
q_85
http://res.cloudinary.com/dougsillars/image/upload/q_85/v1537006839/20180914_142934_v7wn0v.jpg
20%
213 KB
q_20
http://res.cloudinary.com/dougsillars/image/upload/q_20/v1537006839/20180914_142934_v7wn0v.jpg
Graphing the Results
https://developers.google.com/speed/docs/insights/OptimizeImages
Graphing the Results
https://developers.google.com/speed/docs/insights/OptimizeImages
Automate Quality vs. File Size
• Butteraugli
• SSIM: Structural SIMilarity
https://github.com/technopagan/cjpeg-dssim
cjpeg-dssim jpegoptim castle.jpg
http://res.cloudinary.com/dougsillars/image/upload/q_auto/v1537006839/20180914_142934_v7wn0v.jpg
SSIM
870 KB
http://res.cloudinary.com/dougsillars/image/upload/q_auto/v1537006839/20180914_142934_v7wn0v.jpg
Graphing the Results
https://developers.google.com/speed/docs/insights/OptimizeImages
113 KB savings
Results:
• Test Load on Motorola G4:
4 Simple Image Optimizations
1. Quality
2. Format
3. Sizing
4. Lazy Loading
Image Formats – Average Size
HTTPArchive mobile websites 15/02/18
Image Formats – Average Size
HTTPArchive mobile websites 15/02/18
Scalable Vector Graphics (SVG)
Images drawn as shapes
infinitely scalable
XML - Can be added inline to HTML document
https://gist.github.com/hail2u/2884613?short_path=66a60ff
Scalable Vector Graphics (SVG)
Images drawn as shapes
infinitely scalable
XML - Can be added inline to HTML document
https://gist.github.com/hail2u/2884613?short_path=66a60ff
Scalable Vector Graphics (SVG)
Images drawn as shapes
infinitely scalable
XML - Can be added inline to HTML document
https://gist.github.com/hail2u/2884613?short_path=66a60ff
Scalable Vector Graphics (SVG)
Scalable Vector Graphics (SVG)
Scalable Vector Graphics (SVG)
https://github.com/google/brotli
Image Formats – Average Size
HTTPArchive mobile websites 15/02/18
Convert File Format
http://res.cloudinary.com/dougsillars/image/upload/q_auto,f_auto/v1537006839/20180914_142934_v7wn0v.jpg
convert castle_cjpeg_dssim.jpg castle.webp
SSIM + WebP
535 KB
http://res.cloudinary.com/dougsillars/image/upload/q_auto,f_auto/v1537006839/20180914_142934_v7wn0v.jpg
Image Format: WebP
<picture>
<source width = "100%" type="image/webp" srcset=”castle.webp">
<img width = "100%" src=”castle_cjpeg_dssim.jpg"
alt=”Cardiff Castle keep">
</picture>
File Format: WebP
https://caniuse.com/#feat=webp
Image Format Use “In The Wild”
500,000 mobile sites
Analyzed 3/15/18
Image Format Use “In The Wild”
500,000 mobile sites
Analyzed 3/15/18
4 Simple Image Optimizations
1. Quality
2. Format
3. Sizing
4. Lazy Loading
Image Sizing
-
Image Sizing
Image Sizing
-
Image Sizing
624
832
-
Image Sizing
624
832
12,979,000 pixels
519,000 pixels
_________________
-
12,460,000 pixels
Image Sizing
624
832
12,979,000 pixels
519,000 pixels
_________________
-
12,460,000 pixels
Image Sizing
https://twitter.com/paulcalvano/status/928751141843808256
Image Sizing
-
Responsive Images:
Generate a set of images
25 KB difference in size
Responsive Images
624
832
625,000 pixels
-
106,000 pixels
519,000 pixels
_________________
Responsive Breakpoint Generation
https://github.com/cloudinary/responsive_breakpoints_generator
http://www.responsivebreakpoints.com/
Responsive Images
Responsive Images
Responsive Images
Responsive Images Use “In The Wild”
500,000 mobile sites
Analyzed 3/15/18
Responsive Images Use “In The Wild”
442,000 mobile sites
Analyzed 3/15/18
4 Simple Image Optimizations
1. Quality
2. Format
3. Sizing
4. Lazy Loading
Web Usage
https://www.nngroup.com/articles/scrolling-and-attention/
https://calendar.perfplanet.com/2017/progressive-image-loading-using-intersection-observer-and-sqip/
Web Usage
https://www.nngroup.com/articles/scrolling-and-attention/
https://calendar.perfplanet.com/2017/progressive-image-loading-using-intersection-observer-and-sqip/
Lazy Loading
https://www.nngroup.com/articles/scrolling-and-attention/
https://calendar.perfplanet.com/2017/progressive-image-loading-using-intersection-observer-and-sqip/
Lazy Loading Use “In The Wild”
442,000 mobile sites
Analyzed 3/15/18
Lazy Loading Use “In The Wild”
442,000 mobile sites
Analyzed 3/15/18
Lazy Loading
https://www.nngroup.com/articles/scrolling-and-attention/
https://calendar.perfplanet.com/2017/progressive-image-loading-using-intersection-observer-and-sqip/
Preview Images
Optimizing Content Delivery
Preview Images
https://github.com/technopagan/sqip
Preview Images
Animated GIFs
Original MP4
1.4 MB
Animated GIFs
Animated GIFs
Animated GIF
3.8 MB
270% larger
Animated GIFs
Animated GIFs
MP4: 256 colors
247KB
93% smaller
Animated GIFs
Video Tags:
Video is not pre-loaded, will be last to download
<video loop autoplay muted playsinline controls = "false” src="goats.mp4”/>
Img tags are fast!
<picture>
<source type="video/mp4" srcset=”goats.mp4">
<source type="image/webp" srcset=”goats.webp">
<img src=”goats.gif">
</picture>
https://calendar.perfplanet.com/2017/animated-gif-without-the-gif/
Animated GIFs
Video
76
Video
Buffer Rage: a state of uncontrollable
fury or violent anger induced by delayed
or interrupted streaming video content
http://www.ineoquest.com/press-releases/new-research-reveals-buffer-rage-as-techs-newest-epidemic
Video Quality Metrics
1.Does the Video Start?
2.Does the Video Stall?
3.Does it Look Good?
Video Startup
Conviva creen_Streaming_TV_Census_Report_FINAL.pdf
Q1 2018:
Video Startup
Conviva creen_Streaming_TV_Census_Report_FINAL.pdf
Q1 2018: Video Startup
16.9B total Video plays
400M Fail to Start
2B Abandoned before Start
~800M hours of video
playback lost
Video Startup
Conviva creen_Streaming_TV_Census_Report_FINAL.pdf
Q1 2018: Video Startup
16.9B total Video plays
400M Fail to Start
2B Abandoned before Start
~800M hours of video
playback lost
Video Fails To Start
Video Startup Failure
Video Startup
Conviva creen_Streaming_TV_Census_Report_FINAL.pdf
Q1 2018: Video Startup
16.9B total Video plays
400M Fail to Start
2B Abandoned before Start
Video Startup
Conviva creen_Streaming_TV_Census_Report_FINAL.pdf
Q1 2018: Video Startup
Average Video Start Time:
N. America: 4.91s
Asia: 3.00s
Europe: 4.30s
Video Startup Delay
After 2 seconds,
every additional
second corresponds
to 5.8% increase in
abandonment
https://www.akamai.com/kr/ko/multimedia/documents/technical-publication/video-stream-quality-impacts-viewer-behavior-inferring-causality-using-quasi-experimental-designs-technical-publication.pdf
Video Startup Delay
https://www.akamai.com/kr/ko/multimedia/documents/technical-publication/video-stream-quality-impacts-viewer-behavior-inferring-causality-using-quasi-experimental-designs-technical-publication.pdf
3rd Party Interference
3rd Party Interference
3rd Party Interference
Preload When It Makes Sense
Ad Playback Video
Download
Preload When It Makes Sense
Ad Playback Video
Download
Preload When It Makes Sense
Ad Playback
Video
Download
...be Careful with Preload
Preload = “auto”
…be Careful with Preload
Optimizing Video Delivery
What Leads to Startup Delay?
Manifest File:
List of Available
Streams
Player Chooses a Stream Stream Manifest:
List of Video Segments
Player Downloads
Segments into buffer
Video Plays
Optimizing Video Delivery
What Leads to Startup Delay?
Example Manifest file:
Optimizing Video Delivery
Video Streaming
Manifest File:
List of Available
Streams
Player selects
8.5 MBPS stream Stream Manifest:
List of Video Segments
Buffer takes a long
time to fill
Video Does Not Play
Player immediately changes the
stream choice to 192 KBPS
Video Startup
Optimizing Video Delivery
What Leads to Startup Delay?
Example Manifest file:
Optimizing Video Delivery
What Leads to Startup Delay?
Example Manifest file:
Video Startup
Video Startup
Video Startup
Video Startup
10s 11s 12s 13s 14s 15s 16s 17s
4k Low->High:
4K Middle:
4k:High->Low:
Video Startup “In the Wild”
75%
20%
5%
https://dougsillars.com/2018/03/29/streaming-video-whats-on-the-web-today/
Optimizing Content Delivery
Balancing the Network with Playback
Player uses available streams to balance download with playback
Optimizing Content Delivery
Video Streaming
Optimizing Content Delivery
Video Streaming
Large throughput gaps can lead to
many stream changes – which can be
visible to user
Summary
Testing:
WebPageTest https://www.webpagetest.org
HttpArchive https://httparchive.org
Images:
ImageMagick https://www.imagemagick.org
SSIM https://github.com/technopagan/cjpeg-dssim
LazySizes https://github.com/aFarkas/lazysizes
Responsive Breakpoints http://www.responsivebreakpoints.com/
Cloudinary https://www.cloudinary.com
Tooling
Conclusion
Images and Video
can be Beautiful AND Fast
Contest – Win a £100 Amazon Gift Card
Optimize Images for Fast Page Load
Submit your entry by September 21 for a chance to win!
Code and tips: https://github.com/dougsillars/dougsillars.github.io
Entry form: http://bit.ly/FastImages
https://dougsillars.github.io

Mcr fredfastvideoandimages

Editor's Notes

  • #24 47% smaller!
  • #30 1149 bytes, 700 Zipped
  • #31 1149 bytes, 700 Zipped
  • #32 1149 bytes, 700 Zipped
  • #33 1149 bytes, 700 Zipped
  • #34 1149 bytes, 700 Zipped
  • #35 1149 bytes, 700 Zipped
  • #38 47% smaller! Or 65% smaller from original!
  • #67 file:///Users/demo/Documents/reponsiveimages.html