$30 off During Our Annual Pro Sale. View Details »

Mo‘ Pixels Mo‘ Problems

Mo‘ Pixels Mo‘ Problems

How to deal with images in Responsive Web Design

Dave Rupert

May 13, 2013
Tweet

More Decks by Dave Rupert

Other Decks in Design

Transcript

  1. Le menu • Outline the need for responsive images •

    Examine failed paths • Look at our approach at Paravel • Sweet hacks, bro
  2. HTML, CSS, JavaScript, Images, Fonts, Flash?, etc. of page load

    times are because of the front end. 80%
  3. kilobytes == average page weight in April 2013 1,427 kilobytes

    == size of moto.oakley.com 87,962 cost to view moto.oakley.com on Verizon’s smallest plan $22
  4. of RWD sites send the same payload to mobile and

    desktop. 72% Only 6% were “much smaller” http://www.guypo.com/?p=3374
  5. Expect RWD to add about ~10% to your page weight.

    Unofficial findings from the Dave Rupert Research Institute
  6. №3 Retina Screens LOL. YOUR JOB JUST GOT SOOOOoOO MUCH

    MORE DIFFICULT! LOLOLOLOL — Steve Jobs, from the grave.
  7. Strengths Weaknesses GIF Small graphics Animations Colors & alpha PNG

    Small, medium, large images Alpha transparency Large-ish JPG Photos Selective quality Large Data URI Inline (no extra requests) Legacy IE WEBP Small Chrome/Opera only :(
  8. The Paravellian® Approach Use CSS and Web Fonts whenever possible

    Use SVG and Icon Fonts whenever applicable Picturefill raster graphics
  9. @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min--moz-device-pixel-ratio:

    1.5), only screen and (min-resolution: 240dpi) { .pizza { background-image: url("[email protected]"); background-size: 400px 300px; } }
  10. a b c d e f g h i j

    a b c d e f g h i j
  11. February 2012 - #WHATWG IRC Hi! We need a solution

    for responsive images. We have some ideas and we’d like to help. I don’t see what the big deal is, can’t you just use Javascript? :( Go form a community group. ... trots off to form community group
  12. May, 10th 2012 - WHATWG Email List Great! I’ll approve

    it this instant. Thanks best friend ;) Uhhhh... wut? Apple’s thing is easier vis à vis better. We made a thing. It’s called @srcset. We want it.
  13. Also, you need use cases, burden of proof of developer

    sentiment, and a bunch of stuff not required for Apple. Also, community groups aren’t a real thing we consider. You should have been emailing the mailing list, ya dummy. :( End scene.
  14. Strengths Just an attribute Strong “2x” syntax Weaknesses Comma delimited

    values Faux-media query microsyntax Non-intuitive px-based “w” and “h” units Browser determination Polyfill causes the double download
  15. <picture alt="Pizza"> <source srcset="small-1.jpg 1x, small-2.jpg 2x"> <source media="(min-width: 18em)"

    srcset="med-1.jpg 1x, med-2.jpg 2x"> <source media="(min-width: 45em)" srcset="large-1.jpg 1x, large-2.jpg 2x"> <img src="small-1.jpg" alt="Pizza"> </picture>
  16. Strengths Audio/Video element syntax Media-query based Supports non-pixel values Supports

    art direction Uses @srcset’s “2x” powers Fallbacks for unsupported types Weaknesses Verbose “Hard to implement”* * Citation needed
  17. <div data-picture data-alt="A delicious pizza"> <div data-src="small.jpg"></div> <div data-src="medium.jpg" data-media="(min-width:

    400px)"></div> <div data-src="large.jpg" data-media="(min-width: 800px)"></div> <div data-src="extralarge.jpg" data-media="(min-width: 1000px)"></div> <!-- Fallback content for non-JS browsers. Same img src as the initial, unqualified source element. --> <noscript> <img src="external/imgs/small.jpg" alt="A delicious pizza"> </noscript> </div>
  18. Strengths One image tag Legacy sites Weaknesses Blackbox What if

    these services shut down? What if you switch platforms?
  19. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 329" preserveAspectRatio="xMidYMid meet"> <title>Clown Car

    Technique</title> <style> svg { background-size: 100% 100%; background-repeat: no-repeat; } @media screen and (max-width: 400px) { svg {background-image: url(pizza/small.png);} } @media screen and (min-width: 401px) and (max-width: 700px) { svg {background-image: url(pizza/medium.png);} } @media screen and (min-width: 701px) and (max-width: 1000px) { svg {background-image: url(pizza/big.png);} } @media screen and (min-width: 1001px) { svg {background-image: url(pizza/huge.png);} } </style> </svg>