August 2014


Efficiently load properly dimensioned images that fit the page's design




Images - over 63%

Up to™ 72% image data savings

Measures the difference between current images & perfectly sized images
data plan abuse
Large images?
<img src="1x.jpg" srcset="2x.jpg 2x, 3x.jpg 3x"
alt="The president.">

<picture>
<source media="(min-width: 45em)" srcset="large.jpg">
<source media="(min-width: 18em)" srcset="medium.jpg">
<img src="small.jpg" alt="The president.">
</picture>
http://ericportis.com/posts/2014/srcset-sizes/
<img src="otherpic.jpg" alt="The president giving an award."
sizes="(max-width: 30em) 100vw,
(max-width: 50em) 50vw,
calc(33vw - 100px)"
srcset="pic100.jpg 100w, pic200.jpg 200w,
pic400.jpg 400w, pic800.jpg 800w, pic1600.jpg 1600w,
pic3200.jpg 3200w">
<picture>
<source media="(min-width: 80em)"
srcset="fixed_with_bg.1x.jpg 1x, fixed_with_bg.2x.jpg 2x">
<img src="otherpic.jpg" alt="The president giving an award."
sizes="(max-width: 30em) 100vw,
(max-width: 50em) 50vw,
calc(33vw - 100px)"
srcset="pic100.jpg 100w, pic200.jpg 200w,
pic400.jpg 400w, pic800.jpg 800w, pic1600.jpg 1600w,
pic3200.jpg 3200w">
</picture>
Implemented & shipped srcset's 'x' descriptor
Willing to accept patches behind a compile flag
I'm currently working on patches
<picture>
<source media="(min-width: 45em)" srcset="large.jpg">
<source media="(min-width: 18em)" srcset="medium.jpg">
<img src="small.jpg" alt="The president.">
</picture>
!=
<picture>
<source media="(min-width: 18em)" srcset="medium.jpg">
<source media="(min-width: 45em)" srcset="large.jpg">
<img src="small.jpg" alt="The president.">
</picture>
sizes="(max-width: 30em) 100vw,
(max-width: 50em) 50vw,
calc(33vw - 100px)"
!=
sizes="(max-width: 50em) 50vw,
(max-width: 30em) 100vw,
calc(33vw - 100px)"
<img src="otherpic.jpg" alt="The president giving an award."
srcset="pic100.jpg 100w, pic200.jpg 200w">
is identical to
<img src="otherpic.jpg" sizes="100vw"
alt="The president giving an award."
srcset="pic100.jpg 100w, pic200.jpg 200w">


<style>
@viewport {
width: auto;
}
</style>
<img src="otherpic.jpg" alt="The president giving an award."
srcset="pic100.jpg 100w, pic200.jpg 200w">
- Tab Atkins
HTMLImageElement.sizes&HTMLPictureElement
<picture>
<source sizes="100vw"
srcset="pic100.jpg 100w, pic200.jpg 200w">
<img src="otherpic.jpg" sizes="100vw"
alt="The president giving an award."
srcset="pic100.jpg 100w, pic200.jpg 200w">
</picture>
<img src="otherpic.jpg" sizes="100vw"
alt="The president giving an award."
srcset="pic100.jpg 100w, pic200.jpg 200w">
<picture>
<source media="(min-width: 18em)" srcset="medium.jpg">
<source media="(min-width: 45em)" srcset="large.jpg">
<img src="small.jpg" alt="The president.">
</picture>
<picture>
<source media="(min-width: 45em)" srcset="large.jpg">
<source media="(min-width: 18em)" srcset="medium.jpg">
<img src="small.jpg" alt="The president.">
</picture>
<picture>
<source media="(min-width: 45em)" src="large.jpg">
<source media="(min-width: 18em)" src="medium.jpg">
<img src="small.jpg" alt="The president.">
</picture>
<picture>
<source media="(min-width: 45em)" srcset="large.jpg">
<source media="(min-width: 18em)" srcset="medium.jpg">
<img src="small.jpg" alt="The president.">
</picture>
sizes="(max-width: 30em) 100vw,
calc(33vw - 100px),
(max-width: 50em) 50vw"
sizes="(max-width: 30em) 100vw,
(max-width: 50em) 50vw,
calc(33vw - 100px)"
<img src="small.jpg" alt="The president."
srcset="400x200.jpg 600w, 800x400.jpg 1200w">
<img src="small.jpg" alt="The president."
srcset="400x200.jpg 400w, 800x400.jpg 800w">
<img alt="The president." srcset="small.jpg 600w, large.jpg 1200w">
<img alt="The president." src="fallback.jpg"
srcset="small.jpg 600w, large.jpg 1200w">
<img src="small.jpg" alt="The president."
srcset="small.jpg 1x, medium.jpg 1.5x, large.jpg 2x">
<img src="small.jpg" alt="The president."
srcset="medium.jpg 1.5x, large.jpg 2x">
Implicitly relies on 'sizes'
Server confirmation header
Used for intrinsic image sizing
Not sent on initial HTML request
336x635
106x200
211x400
336x635
770x512
200x200
400x288
770x512
@yoavweiss on Twitter & GitHub