Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Responsive Images using <picture> and srcset/sizes
Search
Matt Steele
July 02, 2014
Programming
1
1.2k
Responsive Images using <picture> and srcset/sizes
Matt Steele
July 02, 2014
Tweet
Share
More Decks by Matt Steele
See All by Matt Steele
Upgrading to Angular 2 using ngUpgrade
mattdsteele
0
790
Reactive Programming with RxJS
mattdsteele
0
98
GET TO THE CHOPVAR
mattdsteele
0
150
Using Source Maps in 2015
mattdsteele
0
780
The Decorator Pattern
mattdsteele
0
50
Diving Into the Device API
mattdsteele
1
530
Unit Testing JavaScript when you're Afraid of JavaScript
mattdsteele
3
590
What Zelda Taught Me about Front End Engineering
mattdsteele
5
900
Other Decks in Programming
See All in Programming
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
ソフトウェアの振る舞いに着目し 複雑な要件の開発に立ち向かう
rickyban
0
890
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
690
testcontainers のススメ
sgash708
1
120
ドメインイベント増えすぎ問題
h0r15h0
1
170
return文におけるstd::moveについて
onihusube
1
860
CSC305 Lecture 25
javiergs
PRO
0
130
nekko cloudにおけるProxmox VE利用事例
irumaru
3
420
CSC509 Lecture 14
javiergs
PRO
0
130
Haze - Real time background blurring
chrisbanes
1
510
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
Go の GC の不得意な部分を克服したい
taiyow
2
770
Featured
See All Featured
It's Worth the Effort
3n
183
28k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
GitHub's CSS Performance
jonrohan
1030
460k
Done Done
chrislema
181
16k
What's in a price? How to price your products and services
michaelherold
243
12k
Being A Developer After 40
akosma
87
590k
Facilitating Awesome Meetings
lara
50
6.1k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Statistics for Hackers
jakevdp
796
220k
Producing Creativity
orderedlist
PRO
341
39k
Transcript
Responsive Images @mattdsteele
THIS IS WHY YOU’RE FAT
We’ve put on a little weight.
http://httparchive.org/trends.php#bytesTotal&reqTotal
http://httparchive.org/trends.php#bytesTotal&reqTotal Total Page Weight File Size (KB) 1400 1550 1700
1850 July August September October NovemberDecember January February March April May June
http://httparchive.org/trends.php#bytesTotal&reqTotal Total Page Weight File Size (KB) 1400 1550 1700
1850 July August September October NovemberDecember January February March April May June 1485kb 1521kb 1551kb 1590kb 1614kb 1701kb 1681kb 1710kb 1728kb 1762kb 1775kb 1808kb
http://httparchive.org/interesting.php Bytes Per Page by Content Type
http://httparchive.org/interesting.php Images Bytes Per Page by Content Type
http://httparchive.org/interesting.php HTML Other Flash Stylesheets Scripts Images Bytes Per Page
by Content Type
RETINA- POCALYPSE
None
iPhone 3GS
320x480 iPhone 3GS
320x480 iPhone 3GS iPhone 4
320x480 640x960 (2x) iPhone 3GS iPhone 4
HTC One
1920x1080 (3x) HTC One
“Let’s make it responsive!”
Nexus 10
2560x1600 (2x) Nexus 10
2880x1800 (1.6x) MacBook Pro with Retina Display
None
None
None
320x213 41kb
320x213 41kb
320x213 41kb 640x425 137kb
None
1280x852 400kb
72% Responsive sites serve the same content to desktop &
mobile http://www.guypo.com/uncategorized/real-world-rwd-performance-take-2/
Ugh.
Shortcut: <SVG>
<img src="logo.svg">
9+ SVG
Grunticon github.com/filamentgroup/grunticon
"Vectors are for chumps. I need bitmaps."
None
<picture>
<picture> <img src="fallback.png"> </picture>
<picture> <source media="(min-width: 1000px)" srcset="large.png"> <source media="(min-width: 640px)" srcset="medium.png"> <img
src="fallback.png"> </picture>
<picture> <source media="(min-width: 1000px)" srcset="large.webp" type="image/webp"> <source media="(min-width: 1000px)" srcset="large.png">
<source media="(min-width: 640px)" srcset="medium.png"> <img src="fallback.png"> </picture>
None
None
None
Art Direction
<picture> 38 33 Under Consideration
None
None
Screen Size ⊆ What You Need
None
Viewport Size
Viewport Size Screen Density
Viewport Size Rendered Size Screen Density
Viewport Size Rendered Size Screen Density Image Dimensions
Viewport Size Rendered Size Screen Density Image Dimensions Browser knows?
Viewport Size Rendered Size Screen Density Image Dimensions Browser knows?
✓
Viewport Size Rendered Size Screen Density Image Dimensions Browser knows?
✓ ✓
Viewport Size Rendered Size Screen Density Image Dimensions Browser knows?
✓ ✓ ✗
Viewport Size Rendered Size Screen Density Image Dimensions Browser knows?
✓ ✓ ✗ ✗
Viewport Size Rendered Size Screen Density Image Dimensions
Viewport Size Rendered Size Screen Density Image Dimensions Author knows?
Viewport Size Rendered Size Screen Density Image Dimensions Author knows?
✗ ✗ ✓ ✓
srcset & sizes
Image dimensions srcset="large.jpg 1200w, medium.jpg 640w, small.jpg 320w"
Image dimensions URL srcset="large.jpg 1200w, medium.jpg 640w, small.jpg 320w"
Image dimensions Width URL srcset="large.jpg 1200w, medium.jpg 640w, small.jpg 320w"
Rendered Size sizes="(min-width: 1024px) 300px, (min-width: 640px) 50vw, 100vw"
Rendered Size For this MQ: sizes="(min-width: 1024px) 300px, (min-width: 640px)
50vw, 100vw"
Rendered Size For this MQ: Image renders this big sizes="(min-width:
1024px) 300px, (min-width: 640px) 50vw, 100vw"
Rendered Size For this MQ: Image renders this big Default
sizes="(min-width: 1024px) 300px, (min-width: 640px) 50vw, 100vw"
<img src="small.jpg" alt="A responsive image" srcset="large.jpg 1200w, medium.jpg 640w, small.jpg
320w" sizes="(min-width: 1024px) 300px, (min-width: 640px) 50vw, 100vw">
Screen Densities
Configurable
Configurable •HD Mode
Configurable •HD Mode •Speed Mode
Configurable •HD Mode •Speed Mode •Crappy Network Mode
srcset 32 Under Consideration
Fallbacks built-in
Or: Picturefill http://scottjehl.github.io/picturefill/
Go Forth And Get Skinny
@mattdsteele flic.kr/p/7TH4dc