SlideShare a Scribd company logo
1 of 38
Download to read offline
Delivering Optimized Images on the Modern Web 
Velocity/WebRTC 
Europe, Barcelona 
November 17, 2014 
Joshua Marantz jmarantz@google.com 
Google Make the Web Fast team
Balancing UX, Speed and Ease of Development 
Smartphone Users 
High-latency connectivity 
Relatively small screens 
Slow CPUs, thin pipe to GPUs 
Batteries Stretched Thin 
Varying Browser Capabilities 
Desktop / Retina Tablet Users 
Fast WIFI connection 
Can Display large, dense images 
Powerful CPUs 
Long-lasting Batteries 
Varying Browser Capabilities 
Website Developers 
Limited Time --> Prioritize Content 
User-Generated Content 
Confusing Array of Changing Standards 
Browsers Updating Constantly 
Getting Up To Speed on “Responsive” Techniques
Balancing UX, Speed and Ease of Development 
Smartphone Users 
High-latency connectivity 
Relatively small screens 
Slow CPUs, thin pipe to GPUs 
Batteries Stretched Thin 
Varying Browser Capabilities 
Desktop / Retina Tablet Users 
Fast WIFI connection 
Can Display large, dense images 
Powerful CPUs 
Long-lasting Batteries 
Varying Browser Capabilities 
Website Developers 
Limited Time --> Prioritize Content 
User-Generated Content 
Confusing Array of Changing Standards 
Browsers Updating Constantly 
Getting Up To Speed on “Responsive” Techniques
Delivering A Great Mobile Web Experience 
UX = Performance + Quality 
Mobile Web Performance 
Above-the-fold content delivered in one round trip, 15kb compressed 
Ilya Grigorik: Optimizing the Critical Rendering Path for Instant Mobile Websites - Velocity SC - 2013 
This includes all critical JavaScript, CSS, and Images 
→ inlined base64 low-resolution data URLs 
→ use the most compact format available on client 
Mobile Web Quality 
Deliver images with enough quality to make Retina displays look great 
→ replace low-res images with high-res ones on zoom
Balancing UX, Speed and Ease of Development 
Smartphone Users 
High-latency connectivity 
Relatively small screens 
Slow CPUs, thin pipe to GPUs 
Batteries Stretched Thin 
Varying Browser Capabilities 
Desktop / Retina Tablet Users 
Fast WIFI connection 
Can Display large, dense images 
Powerful CPUs 
Long-lasting Batteries 
Varying Browser Capabilities 
Website Developers 
Limited Time --> Prioritize Content 
User-Generated Content 
Confusing Array of Changing Standards 
Browsers Updating Constantly 
Getting Up To Speed on “Responsive” Techniques
Delivering a great desktop / tablet experience 
● Image-resolution sensitive to pixel density 
● Image-resolution sensitive to zoom-level 
● Maximize system performance using CDNs and proxy-caches
Balancing UX, Speed and Ease of Development 
Smartphone Users 
High-latency connectivity 
Relatively small screens 
Slow CPUs, thin pipe to GPUs 
Batteries Stretched Thin 
Varying Browser Capabilities 
Desktop / Retina Tablet Users 
Fast WIFI connection 
Can Display large, dense images 
Powerful CPUs 
Long-lasting Batteries 
Varying Browser Capabilities 
Website Developers 
Limited Time --> Prioritize Content 
User-Generated Content 
Confusing Array of Changing Standards 
Browsers Updating Constantly 
Getting Up To Speed on “Responsive” Techniques
Website Developers 
Most Website developers are not performance experts 
Most Website developers are not mobile experts 
Most Website developers are not responsive-design experts 
Most Website developers don’t come to Velocity 
Many websites are not owned or maintained by their developers 
contractors, sons-in-law, nephews...
Web Developers View of Web Images 
A simple <img src=....> tag is the easiest way to put images on your site 
Consider sites with lots of web pages 
Each of those have lots of images 
Getting simple ‘img’ tags right may be all we can get in the wild 
But by itself it is not going to make all of your users happy.
The Changing Landscape: Image Formats 
Lossy: JPEG, Webp, JPEG-XR 
Lossless: PNG, Webp, JPEG-XR, GIF, SVG 
Fewer bytes is generally better 
modulo decompression cost 
modulo memory of decompressed image 
Goal: get the whole page to 15k uncompressed, 1 round trip 
we need to squeeze critical images 
need to serve them as base64 data URLs 
http://goldfishforthought.blogspot.com/2010/10/comparison-webp-jpeg-and-jpeg-xr.html 
https://developers.google.com/speed/webp/docs/webp_study 
http://www.smashingmagazine.com/2014/05/14/responsive-images-done-right-guide-picture-srcset/
The Changing Landscape: Overall Browser Share 
http://gs.statcounter.com/#all-browser-ww-monthly-200812-201411
The Changing Landscape: The Ascent Of Mobile 
The Developing World is driving this trend 
And they are largely on 2G 
http://gs.statcounter.com/#desktop+mobile+tablet-comparison-ww-monthly-200812-201411
The Changing Landscape: Mobile-only Browser Share 
UC Browser & Opera 
http://gs.statcounter.com/#mobile_browser-ww-monthly-200812-201411
The Changing Landscape: Browser Image Support, Nov ‘14 
Browser Mobile Market 
Share(*) 
Desktop + Tablet 
Market Share 
WebP Jpeg-XR PNG, Jpeg, Jpeg- 
Progressive, GIF 
IE 0% 20% no Yes (IE9+) Yes 
Chrome 29% 48% Lossy & Lossless no Yes 
Android 21% 0% Lossy no Yes 
Opera 9% 1% Lossy no Yes 
UC Browser 10% 0% ? ? Yes 
Safari / iPhone 22% 11% no no Yes 
Firefox 0% 17% no no Yes 
Nokia 9% 0% no no Yes 
19% of Mobile Browsers designed for low bandwidth (Opera + UC) 
Browsers supporting advanced image formats 
Desktop+Tablet: 69% (Chrome + IE + Opera) 
Mobile: 59% (Android + Opera + Chrome) 
http://gs.statcounter.com/#all-browser-ww-monthly-200812-201405, 
http://gs.statcounter.com/#mobile_browser-ww-monthly-200812-201406-bar
Changing Landscape: Devices 
http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density (+ zooming) 
<img src="image-1x.jpg" width="500" height="500"> 
Old: New: 
CSS pixel == device pixel CSS pixel ≠ device pixel
Recent Apple device resolutions 
Model Generations Diagonal cm (in) Resolution PPCM (PPI) CSS pixel ratio 
iPad 1st gen, 2 gen 25 (9.7) 1024x768 52 (132) 1 
People who buy Retina iPads have 
beautiful devices and want to see 
beautiful images on them 
iPad / iPad Air 3rd gen, 4th gen 25 (9.7) 2048x1536 104 (264) 2 
iPad Mini 1st gen 20 (7.9) 1024x768 64 (163) 1 
iPad Mini 2nd gen 20 (7.9) 2048x1536 128 (326) 2 
iPhone 3GS 3 / 3rd gen 8.9 (3.5) 320x480 64 (163) 1 
iPhone 4 4 / 4th gen 8.9 (3.5) 960x640 128 (326) 2 
MBP 13” 2009-2012 34 (13.3) 1280x800 44 (113) 1 
MBP 13” Retina 2012-2013 34 (13.3) 2560x1600 89 (227) 2
Challenges with simple <img src=> tag 
All parameters for optimization not known in one place 
The browser doesn’t know the image dimensions are quality before 
downloading 
The server does not know the pixel density or device performance based in the 
request 
Thus was born srcset: http://www.w3.org/html/wg/drafts/srcset/w3c-srcset/ 
(published June 26, 2014)
srcset browser support 
Fortunately, Graceful fallback to src= attribute means you can use srcset and it will not harm other browsers 
http://caniuse.com/#feat=srcset
Don’t forget the users! 
Who are your users? 
How are they connected? 
What browsers do they use? 
Do you care... 
whether your site is beautiful on a modern tablet / computer? 
if your site works properly on a variety of older browsers 
if your site performs well on a mobile phone on Edge/3G/LTE?
Anatomy of a reasonable Image tag 
<img src="image-1x.jpg" 
srcset="image-2x.jpg 2x, image-4x.jpg 4x"> 
Available in Chrome, Safari, & Firefox 
Extra attributes will be safely ignored by other browsers until they add this 
capability 
Delivers the right quality images to most modern phones and tablets
srcset specification flexibility 
The srcset attribute allows authors to provide a set of images to handle graphical 
displays of varying dimensions and pixel densities. 
The attribute essentially takes a comma-separated list of URLs each with one or 
more descriptors giving the maximum viewport dimensions and pixel density 
allowed to use the image. From the available options, the user agent then picks 
the most appropriate image. If the viewport dimensions or pixel density 
changes, the user agent can replace the image data with a new image on 
the fly. 
To specify an image, give first a URL, then one or more descriptors of the form 
100w or 2x, where "100w" means "maximum viewport width of 100 CSS pixels" 
and "2x" means "maximum pixel density of 2 device pixels per CSS pixel".
Srcset Observations in Chrome & Safari 
Chrome Safari 
Selects images on Page Load Yes Yes 
Selects images on Control-+ No No 
‘onresize’ on Control-+ Yes Yes 
‘onresize’ on Pinch-Zoom No Yes 
‘ontouchstart’ Yes Yes 
srcset helps Responsive Design, but is not dynamic by default
Dynamic Image Refinement “polyfills” 
function upgradeImage(img) { 
var hiRes = getSourceForCurrentResolution(img); 
if (img.src != hiRes) { 
var hiResImg = new Image(); 
hiResImg.onload = function() { img.src = hiRes; } 
hiResImg.src = hiRes; 
} 
} 
Control-+ for Desktop devices Pinch-Zoom for Mobile Devices 
window.addEventListener(‘resize’, function() { 
foreach img { upgradeImage(img); } 
}); 
foreach img { 
img.addEventListener(‘touchstart’, function() { 
upgradeImage(img); 
}); 
}
Why Add This JS? Can’t Browsers Do This? 
Game Plan: 
Deliver a low-res view of the web page in 15k bytes compressed 
no external resources 
Fill in detail dynamically as user expresses interest 
srcset is not (AFAICT) intended for this, but it could be
Resized image with simple img tag 
1.3 meg is way too many 
bytes for these pixels 
And too slow, even 
with server & client 
on same machine
Optimized/sized images are 90% smaller & look great... 
3.3 K: small enough to 
inline if the images are 
critical to the page
...until you zoom in; browser scaling looks terrible
Add “srcset” and polyfill for Zoom Sensitivity 
1.1k JavaScript “polyfill” 
replaces lower-res images 
with higher-res images when 
user zooms in with Control-+. 
+ Enables ‘srcset’ on all 
browsers with JS!
Demo
Delivering the best image format in markup 
<picture> and <source> can be combined to select webp images to compatible 
browsers (Chrome, Opera) 
https://html.spec.whatwg.org/multipage/embedded-content.html#introduction-3:attr-picture-source-type 
<picture> 
<source srcset="/uploads/100-marie-lloyd.webp" type="image/webp"> 
<source srcset="/uploads/100-marie-lloyd.jxr" type="image/vnd.ms-photo"> 
<img src="/uploads/100-marie-lloyd.jpg" alt="" width="100" height="150"> 
</picture>
Delivering the best image format in the server 
Change the URL 
● Web Performance Optimization 
mod_pagespeed etc, Akamai Aqua Ion, Radware 
● Embedded in Web App (Facebook, Google+) 
● Risks: subtly interfering with JavaScript introspection 
http://mzoom.org/588x440xwintercharles.jpg.pagespeed.ic.iVgBCAHftt.webp 
Leave the URL alone 
● Serve webp but to .jpg URL 
● Use Vary:Accept 
● Proxy-caches & CDNs need to cache responses with Vary:Accept
Hints From The HTTP Request 
User-Agent Accept 
IE 11 Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv: 
11.0) like Gecko 
text/html, application/xhtml+xml, */* 
Chrome Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35. 
0.1916.153 Safari/537.36 
text/html,application/xhtml+xml, 
application/xml;q=0.9,image/webp,*/*; 
q=0.8 
Firefox Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) 
Gecko/20100101 Firefox/30.0 
text/html,application/xhtml+xml, 
application/xml;q=0.9,*/*;q=0.8 
Safari Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) 
AppleWebKit/537.76.4 
text/html,application/xhtml+xml, 
application/xml;q=0.9,*/*;q=0.8 
Opera Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35. 
0.1916.153 Safari/537.36 OPR/22.0.1471.70 
text/html,application/xhtml+xml, 
application/xml;q=0.9,image/webp,*/*; 
q=0.8
Content Delivery Networks 
Proxy Caches situated closer to users than your origin 
Maps URLs + X? -> Content (Content-Type) 
But what if you want to serve different content to modern browsers? 
Vary:Accept 
Vary:User-Agent 
One concern: Proxy Cache Fragmentation
Local Proxy Cache 
Handles cached requests much faster than typical origin 
servers 
Varnish 
Squid 
Apache Traffic Server 
nginx 
Same issues with CDNs: Vary handling
Getting the Details Right: Internet Explorer 
Add Vary:Accept in your response headers 
IE will have to validate browser cache hits (!!) 
Omit Vary:Accept in your response headers 
Proxy caches and CDNs can deliver the wrong content, so use Cache- 
Control:private 
Strip Vary:Accept at the last point you control: proxy cache or CDN 
ModPagespeedEnableFilters in_place_optimize_for_browser 
ModPagespeedPrivateNotVaryForIE off 
https://developers.google.com/speed/pagespeed/module/system#in_place_optimize_for_browser
Getting the Details Right: Amazon EC2 
HTTP Requests for origin images from EC2 are served with 
User-Agent + Accept headers stripped (!!!) 
→ We must serve distinct URLs for webp, avoid optimizing in-place 
for sites using EC2 as a CDN
Making A Better Web 
→ Evangelize web development best practices 
→ Make faster browsers 
→ Make better CDNs 
→ Automate content generation to exploit browsers & CDNs
Delivering Optimized Images On The Modern Web 
In 2014, browsers, CDNs, and WPO tools are make this easier 
Effective use of srcset (with help of dynamic polyfills) 
Try It Yourself: http://mzoom.org [through November 2014] 
Sending superior image formats to modern browsers 
Effective Use of CDNs and Proxy Caches

More Related Content

What's hot

Service workers your applications never felt so good
Service workers   your applications never felt so goodService workers   your applications never felt so good
Service workers your applications never felt so goodChris Love
 
The Physical World meets the Web
The Physical World meets the WebThe Physical World meets the Web
The Physical World meets the WebMaximiliano Firtman
 
Cloud Camp Chicago Dec 2012 Slides
Cloud Camp Chicago Dec 2012 SlidesCloud Camp Chicago Dec 2012 Slides
Cloud Camp Chicago Dec 2012 SlidesRyan Koop
 
HTML5 or Android for Mobile Development?
HTML5 or Android for Mobile Development?HTML5 or Android for Mobile Development?
HTML5 or Android for Mobile Development?Reto Meier
 
Performance as UX with Justin Howlett
Performance as UX with Justin HowlettPerformance as UX with Justin Howlett
Performance as UX with Justin HowlettFITC
 
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...Nicholas Jansma
 
Measuring Web Performance (HighEdWeb FL Edition)
Measuring Web Performance (HighEdWeb FL Edition)Measuring Web Performance (HighEdWeb FL Edition)
Measuring Web Performance (HighEdWeb FL Edition)Dave Olsen
 
Sg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanleySg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanleyn_adam_stanley
 
Desktop Applications with NetBeans
Desktop Applications with NetBeansDesktop Applications with NetBeans
Desktop Applications with NetBeansHuu Bang Le Phan
 
Its timetostopstalling mot_paris
Its timetostopstalling mot_parisIts timetostopstalling mot_paris
Its timetostopstalling mot_parisDoug Sillars
 
QNX, C/C++, Qt, Cascades, HTML5… So what’s now BlackBerry 10 application deve...
QNX, C/C++, Qt, Cascades, HTML5… So what’s now BlackBerry 10 application deve...QNX, C/C++, Qt, Cascades, HTML5… So what’s now BlackBerry 10 application deve...
QNX, C/C++, Qt, Cascades, HTML5… So what’s now BlackBerry 10 application deve...Codemotion
 
Improving frontend performance
Improving frontend performanceImproving frontend performance
Improving frontend performanceSagar Desarda
 
RIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdgRIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdgZiyad Bazed
 
Performance Implications of Mobile Design
Performance Implications of Mobile DesignPerformance Implications of Mobile Design
Performance Implications of Mobile DesignGuy Podjarny
 
Mobile Web Best Practices
Mobile Web Best PracticesMobile Web Best Practices
Mobile Web Best PracticesJames D Bloom
 
Responsive Images and Performance
Responsive Images and PerformanceResponsive Images and Performance
Responsive Images and PerformanceMaximiliano Firtman
 
Qa fest kiev_when its just too slow
Qa fest kiev_when its just too slowQa fest kiev_when its just too slow
Qa fest kiev_when its just too slowDoug Sillars
 

What's hot (18)

Service workers your applications never felt so good
Service workers   your applications never felt so goodService workers   your applications never felt so good
Service workers your applications never felt so good
 
The Physical World meets the Web
The Physical World meets the WebThe Physical World meets the Web
The Physical World meets the Web
 
Cloud Camp Chicago Dec 2012 Slides
Cloud Camp Chicago Dec 2012 SlidesCloud Camp Chicago Dec 2012 Slides
Cloud Camp Chicago Dec 2012 Slides
 
HTML5 or Android for Mobile Development?
HTML5 or Android for Mobile Development?HTML5 or Android for Mobile Development?
HTML5 or Android for Mobile Development?
 
Performance as UX with Justin Howlett
Performance as UX with Justin HowlettPerformance as UX with Justin Howlett
Performance as UX with Justin Howlett
 
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
Make It Fast - Using Modern Browser Performance APIs to Monitor and Improve t...
 
Measuring Web Performance (HighEdWeb FL Edition)
Measuring Web Performance (HighEdWeb FL Edition)Measuring Web Performance (HighEdWeb FL Edition)
Measuring Web Performance (HighEdWeb FL Edition)
 
Sg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanleySg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanley
 
Desktop Applications with NetBeans
Desktop Applications with NetBeansDesktop Applications with NetBeans
Desktop Applications with NetBeans
 
Its timetostopstalling mot_paris
Its timetostopstalling mot_parisIts timetostopstalling mot_paris
Its timetostopstalling mot_paris
 
QNX, C/C++, Qt, Cascades, HTML5… So what’s now BlackBerry 10 application deve...
QNX, C/C++, Qt, Cascades, HTML5… So what’s now BlackBerry 10 application deve...QNX, C/C++, Qt, Cascades, HTML5… So what’s now BlackBerry 10 application deve...
QNX, C/C++, Qt, Cascades, HTML5… So what’s now BlackBerry 10 application deve...
 
Improving frontend performance
Improving frontend performanceImproving frontend performance
Improving frontend performance
 
RIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdgRIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdg
 
Performance Implications of Mobile Design
Performance Implications of Mobile DesignPerformance Implications of Mobile Design
Performance Implications of Mobile Design
 
Progressive Web Apps - NPD Meet
Progressive Web Apps - NPD MeetProgressive Web Apps - NPD Meet
Progressive Web Apps - NPD Meet
 
Mobile Web Best Practices
Mobile Web Best PracticesMobile Web Best Practices
Mobile Web Best Practices
 
Responsive Images and Performance
Responsive Images and PerformanceResponsive Images and Performance
Responsive Images and Performance
 
Qa fest kiev_when its just too slow
Qa fest kiev_when its just too slowQa fest kiev_when its just too slow
Qa fest kiev_when its just too slow
 

Similar to Delivering Optimal Images for Phones and Tablets on the Modern Web

Images blast off at the speed of Jamstack! - Alba Silvente Fuentes
Images blast off at the speed of Jamstack! - Alba Silvente FuentesImages blast off at the speed of Jamstack! - Alba Silvente Fuentes
Images blast off at the speed of Jamstack! - Alba Silvente FuentesWey Wey Web
 
Better DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen WorldBetter DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen WorldJoe Pairman
 
[cssdevconf] Adaptive Images in RWD
[cssdevconf] Adaptive Images in RWD[cssdevconf] Adaptive Images in RWD
[cssdevconf] Adaptive Images in RWDChristopher Schmitt
 
Intro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS featuresIntro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS featuresAndreas Bovens
 
Alexa IT Solution Responsive Web designing
Alexa IT Solution Responsive Web designingAlexa IT Solution Responsive Web designing
Alexa IT Solution Responsive Web designingRavi Panchal
 
An Introduction to Responsive Design
An Introduction to Responsive DesignAn Introduction to Responsive Design
An Introduction to Responsive DesignValtech UK
 
[rwdsummit2012] Adaptive Images in Responsive Web Design
[rwdsummit2012] Adaptive Images in Responsive Web Design[rwdsummit2012] Adaptive Images in Responsive Web Design
[rwdsummit2012] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
Intro to Responsive Web Design
Intro to Responsive Web DesignIntro to Responsive Web Design
Intro to Responsive Web Designmeghantaylor
 
SMX Milan - Supercharge Responsive Design | Idea Evolver
SMX Milan - Supercharge Responsive Design | Idea EvolverSMX Milan - Supercharge Responsive Design | Idea Evolver
SMX Milan - Supercharge Responsive Design | Idea EvolverIdea Evolver
 
Optimize Images for SEO WordCamp Sacramento
Optimize Images for SEO WordCamp SacramentoOptimize Images for SEO WordCamp Sacramento
Optimize Images for SEO WordCamp SacramentoLeslie Staller
 
Pinkoi Mobile Web
Pinkoi Mobile WebPinkoi Mobile Web
Pinkoi Mobile Webmikeleeme
 
Drupalcon Asia - "Drupal 8 Mobile in its DNA"
Drupalcon Asia - "Drupal 8 Mobile in its DNA"Drupalcon Asia - "Drupal 8 Mobile in its DNA"
Drupalcon Asia - "Drupal 8 Mobile in its DNA"Ram Singh
 
[html5tx] Adaptive Images in Responsive Web Design
[html5tx] Adaptive Images in Responsive Web Design[html5tx] Adaptive Images in Responsive Web Design
[html5tx] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
Mo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent Web
Mo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent WebMo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent Web
Mo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent WebRita Troyer
 
[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
Responsive design and retina displays
Responsive design and retina displaysResponsive design and retina displays
Responsive design and retina displaysEli McMakin
 

Similar to Delivering Optimal Images for Phones and Tablets on the Modern Web (20)

Images blast off at the speed of Jamstack! - Alba Silvente Fuentes
Images blast off at the speed of Jamstack! - Alba Silvente FuentesImages blast off at the speed of Jamstack! - Alba Silvente Fuentes
Images blast off at the speed of Jamstack! - Alba Silvente Fuentes
 
Presentation on Fresco
Presentation on FrescoPresentation on Fresco
Presentation on Fresco
 
Tangoe matrix sprint 15 usable and light weight user interface demo - sep -...
Tangoe matrix sprint 15 usable and light weight user interface   demo - sep -...Tangoe matrix sprint 15 usable and light weight user interface   demo - sep -...
Tangoe matrix sprint 15 usable and light weight user interface demo - sep -...
 
Better DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen WorldBetter DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen World
 
[cssdevconf] Adaptive Images in RWD
[cssdevconf] Adaptive Images in RWD[cssdevconf] Adaptive Images in RWD
[cssdevconf] Adaptive Images in RWD
 
Intro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS featuresIntro to @viewport & other new Responsive Web Design CSS features
Intro to @viewport & other new Responsive Web Design CSS features
 
Alexa IT Solution Responsive Web designing
Alexa IT Solution Responsive Web designingAlexa IT Solution Responsive Web designing
Alexa IT Solution Responsive Web designing
 
An Introduction to Responsive Design
An Introduction to Responsive DesignAn Introduction to Responsive Design
An Introduction to Responsive Design
 
[rwdsummit2012] Adaptive Images in Responsive Web Design
[rwdsummit2012] Adaptive Images in Responsive Web Design[rwdsummit2012] Adaptive Images in Responsive Web Design
[rwdsummit2012] Adaptive Images in Responsive Web Design
 
Intro to Responsive Web Design
Intro to Responsive Web DesignIntro to Responsive Web Design
Intro to Responsive Web Design
 
SMX Milan - Supercharge Responsive Design | Idea Evolver
SMX Milan - Supercharge Responsive Design | Idea EvolverSMX Milan - Supercharge Responsive Design | Idea Evolver
SMX Milan - Supercharge Responsive Design | Idea Evolver
 
Optimize Images for SEO WordCamp Sacramento
Optimize Images for SEO WordCamp SacramentoOptimize Images for SEO WordCamp Sacramento
Optimize Images for SEO WordCamp Sacramento
 
Pinkoi Mobile Web
Pinkoi Mobile WebPinkoi Mobile Web
Pinkoi Mobile Web
 
Drupalcon Asia - "Drupal 8 Mobile in its DNA"
Drupalcon Asia - "Drupal 8 Mobile in its DNA"Drupalcon Asia - "Drupal 8 Mobile in its DNA"
Drupalcon Asia - "Drupal 8 Mobile in its DNA"
 
[html5tx] Adaptive Images in Responsive Web Design
[html5tx] Adaptive Images in Responsive Web Design[html5tx] Adaptive Images in Responsive Web Design
[html5tx] Adaptive Images in Responsive Web Design
 
Responding Responsively
Responding ResponsivelyResponding Responsively
Responding Responsively
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design
 
Mo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent Web
Mo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent WebMo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent Web
Mo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent Web
 
[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design
 
Responsive design and retina displays
Responsive design and retina displaysResponsive design and retina displays
Responsive design and retina displays
 

Recently uploaded

Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Delivering Optimal Images for Phones and Tablets on the Modern Web

  • 1. Delivering Optimized Images on the Modern Web Velocity/WebRTC Europe, Barcelona November 17, 2014 Joshua Marantz jmarantz@google.com Google Make the Web Fast team
  • 2. Balancing UX, Speed and Ease of Development Smartphone Users High-latency connectivity Relatively small screens Slow CPUs, thin pipe to GPUs Batteries Stretched Thin Varying Browser Capabilities Desktop / Retina Tablet Users Fast WIFI connection Can Display large, dense images Powerful CPUs Long-lasting Batteries Varying Browser Capabilities Website Developers Limited Time --> Prioritize Content User-Generated Content Confusing Array of Changing Standards Browsers Updating Constantly Getting Up To Speed on “Responsive” Techniques
  • 3. Balancing UX, Speed and Ease of Development Smartphone Users High-latency connectivity Relatively small screens Slow CPUs, thin pipe to GPUs Batteries Stretched Thin Varying Browser Capabilities Desktop / Retina Tablet Users Fast WIFI connection Can Display large, dense images Powerful CPUs Long-lasting Batteries Varying Browser Capabilities Website Developers Limited Time --> Prioritize Content User-Generated Content Confusing Array of Changing Standards Browsers Updating Constantly Getting Up To Speed on “Responsive” Techniques
  • 4. Delivering A Great Mobile Web Experience UX = Performance + Quality Mobile Web Performance Above-the-fold content delivered in one round trip, 15kb compressed Ilya Grigorik: Optimizing the Critical Rendering Path for Instant Mobile Websites - Velocity SC - 2013 This includes all critical JavaScript, CSS, and Images → inlined base64 low-resolution data URLs → use the most compact format available on client Mobile Web Quality Deliver images with enough quality to make Retina displays look great → replace low-res images with high-res ones on zoom
  • 5. Balancing UX, Speed and Ease of Development Smartphone Users High-latency connectivity Relatively small screens Slow CPUs, thin pipe to GPUs Batteries Stretched Thin Varying Browser Capabilities Desktop / Retina Tablet Users Fast WIFI connection Can Display large, dense images Powerful CPUs Long-lasting Batteries Varying Browser Capabilities Website Developers Limited Time --> Prioritize Content User-Generated Content Confusing Array of Changing Standards Browsers Updating Constantly Getting Up To Speed on “Responsive” Techniques
  • 6. Delivering a great desktop / tablet experience ● Image-resolution sensitive to pixel density ● Image-resolution sensitive to zoom-level ● Maximize system performance using CDNs and proxy-caches
  • 7. Balancing UX, Speed and Ease of Development Smartphone Users High-latency connectivity Relatively small screens Slow CPUs, thin pipe to GPUs Batteries Stretched Thin Varying Browser Capabilities Desktop / Retina Tablet Users Fast WIFI connection Can Display large, dense images Powerful CPUs Long-lasting Batteries Varying Browser Capabilities Website Developers Limited Time --> Prioritize Content User-Generated Content Confusing Array of Changing Standards Browsers Updating Constantly Getting Up To Speed on “Responsive” Techniques
  • 8. Website Developers Most Website developers are not performance experts Most Website developers are not mobile experts Most Website developers are not responsive-design experts Most Website developers don’t come to Velocity Many websites are not owned or maintained by their developers contractors, sons-in-law, nephews...
  • 9. Web Developers View of Web Images A simple <img src=....> tag is the easiest way to put images on your site Consider sites with lots of web pages Each of those have lots of images Getting simple ‘img’ tags right may be all we can get in the wild But by itself it is not going to make all of your users happy.
  • 10. The Changing Landscape: Image Formats Lossy: JPEG, Webp, JPEG-XR Lossless: PNG, Webp, JPEG-XR, GIF, SVG Fewer bytes is generally better modulo decompression cost modulo memory of decompressed image Goal: get the whole page to 15k uncompressed, 1 round trip we need to squeeze critical images need to serve them as base64 data URLs http://goldfishforthought.blogspot.com/2010/10/comparison-webp-jpeg-and-jpeg-xr.html https://developers.google.com/speed/webp/docs/webp_study http://www.smashingmagazine.com/2014/05/14/responsive-images-done-right-guide-picture-srcset/
  • 11. The Changing Landscape: Overall Browser Share http://gs.statcounter.com/#all-browser-ww-monthly-200812-201411
  • 12. The Changing Landscape: The Ascent Of Mobile The Developing World is driving this trend And they are largely on 2G http://gs.statcounter.com/#desktop+mobile+tablet-comparison-ww-monthly-200812-201411
  • 13. The Changing Landscape: Mobile-only Browser Share UC Browser & Opera http://gs.statcounter.com/#mobile_browser-ww-monthly-200812-201411
  • 14. The Changing Landscape: Browser Image Support, Nov ‘14 Browser Mobile Market Share(*) Desktop + Tablet Market Share WebP Jpeg-XR PNG, Jpeg, Jpeg- Progressive, GIF IE 0% 20% no Yes (IE9+) Yes Chrome 29% 48% Lossy & Lossless no Yes Android 21% 0% Lossy no Yes Opera 9% 1% Lossy no Yes UC Browser 10% 0% ? ? Yes Safari / iPhone 22% 11% no no Yes Firefox 0% 17% no no Yes Nokia 9% 0% no no Yes 19% of Mobile Browsers designed for low bandwidth (Opera + UC) Browsers supporting advanced image formats Desktop+Tablet: 69% (Chrome + IE + Opera) Mobile: 59% (Android + Opera + Chrome) http://gs.statcounter.com/#all-browser-ww-monthly-200812-201405, http://gs.statcounter.com/#mobile_browser-ww-monthly-200812-201406-bar
  • 15. Changing Landscape: Devices http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density (+ zooming) <img src="image-1x.jpg" width="500" height="500"> Old: New: CSS pixel == device pixel CSS pixel ≠ device pixel
  • 16. Recent Apple device resolutions Model Generations Diagonal cm (in) Resolution PPCM (PPI) CSS pixel ratio iPad 1st gen, 2 gen 25 (9.7) 1024x768 52 (132) 1 People who buy Retina iPads have beautiful devices and want to see beautiful images on them iPad / iPad Air 3rd gen, 4th gen 25 (9.7) 2048x1536 104 (264) 2 iPad Mini 1st gen 20 (7.9) 1024x768 64 (163) 1 iPad Mini 2nd gen 20 (7.9) 2048x1536 128 (326) 2 iPhone 3GS 3 / 3rd gen 8.9 (3.5) 320x480 64 (163) 1 iPhone 4 4 / 4th gen 8.9 (3.5) 960x640 128 (326) 2 MBP 13” 2009-2012 34 (13.3) 1280x800 44 (113) 1 MBP 13” Retina 2012-2013 34 (13.3) 2560x1600 89 (227) 2
  • 17. Challenges with simple <img src=> tag All parameters for optimization not known in one place The browser doesn’t know the image dimensions are quality before downloading The server does not know the pixel density or device performance based in the request Thus was born srcset: http://www.w3.org/html/wg/drafts/srcset/w3c-srcset/ (published June 26, 2014)
  • 18. srcset browser support Fortunately, Graceful fallback to src= attribute means you can use srcset and it will not harm other browsers http://caniuse.com/#feat=srcset
  • 19. Don’t forget the users! Who are your users? How are they connected? What browsers do they use? Do you care... whether your site is beautiful on a modern tablet / computer? if your site works properly on a variety of older browsers if your site performs well on a mobile phone on Edge/3G/LTE?
  • 20. Anatomy of a reasonable Image tag <img src="image-1x.jpg" srcset="image-2x.jpg 2x, image-4x.jpg 4x"> Available in Chrome, Safari, & Firefox Extra attributes will be safely ignored by other browsers until they add this capability Delivers the right quality images to most modern phones and tablets
  • 21. srcset specification flexibility The srcset attribute allows authors to provide a set of images to handle graphical displays of varying dimensions and pixel densities. The attribute essentially takes a comma-separated list of URLs each with one or more descriptors giving the maximum viewport dimensions and pixel density allowed to use the image. From the available options, the user agent then picks the most appropriate image. If the viewport dimensions or pixel density changes, the user agent can replace the image data with a new image on the fly. To specify an image, give first a URL, then one or more descriptors of the form 100w or 2x, where "100w" means "maximum viewport width of 100 CSS pixels" and "2x" means "maximum pixel density of 2 device pixels per CSS pixel".
  • 22. Srcset Observations in Chrome & Safari Chrome Safari Selects images on Page Load Yes Yes Selects images on Control-+ No No ‘onresize’ on Control-+ Yes Yes ‘onresize’ on Pinch-Zoom No Yes ‘ontouchstart’ Yes Yes srcset helps Responsive Design, but is not dynamic by default
  • 23. Dynamic Image Refinement “polyfills” function upgradeImage(img) { var hiRes = getSourceForCurrentResolution(img); if (img.src != hiRes) { var hiResImg = new Image(); hiResImg.onload = function() { img.src = hiRes; } hiResImg.src = hiRes; } } Control-+ for Desktop devices Pinch-Zoom for Mobile Devices window.addEventListener(‘resize’, function() { foreach img { upgradeImage(img); } }); foreach img { img.addEventListener(‘touchstart’, function() { upgradeImage(img); }); }
  • 24. Why Add This JS? Can’t Browsers Do This? Game Plan: Deliver a low-res view of the web page in 15k bytes compressed no external resources Fill in detail dynamically as user expresses interest srcset is not (AFAICT) intended for this, but it could be
  • 25. Resized image with simple img tag 1.3 meg is way too many bytes for these pixels And too slow, even with server & client on same machine
  • 26. Optimized/sized images are 90% smaller & look great... 3.3 K: small enough to inline if the images are critical to the page
  • 27. ...until you zoom in; browser scaling looks terrible
  • 28. Add “srcset” and polyfill for Zoom Sensitivity 1.1k JavaScript “polyfill” replaces lower-res images with higher-res images when user zooms in with Control-+. + Enables ‘srcset’ on all browsers with JS!
  • 29. Demo
  • 30. Delivering the best image format in markup <picture> and <source> can be combined to select webp images to compatible browsers (Chrome, Opera) https://html.spec.whatwg.org/multipage/embedded-content.html#introduction-3:attr-picture-source-type <picture> <source srcset="/uploads/100-marie-lloyd.webp" type="image/webp"> <source srcset="/uploads/100-marie-lloyd.jxr" type="image/vnd.ms-photo"> <img src="/uploads/100-marie-lloyd.jpg" alt="" width="100" height="150"> </picture>
  • 31. Delivering the best image format in the server Change the URL ● Web Performance Optimization mod_pagespeed etc, Akamai Aqua Ion, Radware ● Embedded in Web App (Facebook, Google+) ● Risks: subtly interfering with JavaScript introspection http://mzoom.org/588x440xwintercharles.jpg.pagespeed.ic.iVgBCAHftt.webp Leave the URL alone ● Serve webp but to .jpg URL ● Use Vary:Accept ● Proxy-caches & CDNs need to cache responses with Vary:Accept
  • 32. Hints From The HTTP Request User-Agent Accept IE 11 Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv: 11.0) like Gecko text/html, application/xhtml+xml, */* Chrome Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35. 0.1916.153 Safari/537.36 text/html,application/xhtml+xml, application/xml;q=0.9,image/webp,*/*; q=0.8 Firefox Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0 text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8 Safari Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.76.4 text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8 Opera Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35. 0.1916.153 Safari/537.36 OPR/22.0.1471.70 text/html,application/xhtml+xml, application/xml;q=0.9,image/webp,*/*; q=0.8
  • 33. Content Delivery Networks Proxy Caches situated closer to users than your origin Maps URLs + X? -> Content (Content-Type) But what if you want to serve different content to modern browsers? Vary:Accept Vary:User-Agent One concern: Proxy Cache Fragmentation
  • 34. Local Proxy Cache Handles cached requests much faster than typical origin servers Varnish Squid Apache Traffic Server nginx Same issues with CDNs: Vary handling
  • 35. Getting the Details Right: Internet Explorer Add Vary:Accept in your response headers IE will have to validate browser cache hits (!!) Omit Vary:Accept in your response headers Proxy caches and CDNs can deliver the wrong content, so use Cache- Control:private Strip Vary:Accept at the last point you control: proxy cache or CDN ModPagespeedEnableFilters in_place_optimize_for_browser ModPagespeedPrivateNotVaryForIE off https://developers.google.com/speed/pagespeed/module/system#in_place_optimize_for_browser
  • 36. Getting the Details Right: Amazon EC2 HTTP Requests for origin images from EC2 are served with User-Agent + Accept headers stripped (!!!) → We must serve distinct URLs for webp, avoid optimizing in-place for sites using EC2 as a CDN
  • 37. Making A Better Web → Evangelize web development best practices → Make faster browsers → Make better CDNs → Automate content generation to exploit browsers & CDNs
  • 38. Delivering Optimized Images On The Modern Web In 2014, browsers, CDNs, and WPO tools are make this easier Effective use of srcset (with help of dynamic polyfills) Try It Yourself: http://mzoom.org [through November 2014] Sending superior image formats to modern browsers Effective Use of CDNs and Proxy Caches