Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building websites for HiDPI devices

Vinay M
March 23, 2013

Building websites for HiDPI devices

Presented at front end meetup Singapore

Vinay M

March 23, 2013
Tweet

More Decks by Vinay M

Other Decks in Technology

Transcript

  1. The web’s primary design principle is universality... it should be

    accessible from any kind of hardware that can connect to the Internet: stationary or mobile, small screen or large. — Tim Berners-Lee
  2. HTC Jbutterfly Pixel Ratio: 3 PPI: 440 Samsung SIV Pixel

    Ratio: 2 PPI: 441 iPhone 5 Pixel Ratio: 2 PPI: 326 Mobile Devices
  3. PPI (Pixels per inch) 320+ PPI 240 PPI 160 PPI

    120 PPI Extra HiDPI Baseline for mobile devices
  4. High DPI • Greater pixel density • Physical Resolution is

    higher (2x) • Content Resolution is constant • Content Scale is higher (2x)
  5. How do we target devices • CSS • Javascript •

    Built-in browser features • Server side delivery of images
  6. CSS: device-pixel-ratio • Pros – Downloads the right image based

    on pixel-ratio • Cons – No support for <img > – High DPI device will download large image on Low Bandwidth connection – Multiple Image versions
  7. CSS: IMAGE-SET • Only Supports Background Images • Chrome and

    Safari support ONLY CHROME & SAFARI, POLYFILL
  8. Browser features • Srcset • Polyfill: https://github.com/borismus/srcset-polyfill/ No browser support

    yet. But its in the specs. http://www.w3.org/html/wg/drafts/srcset/w3c-srcset/ POLYFILL
  9. <picture> • Still in the W3C first working draft •

    Polyfill: https://github.com/scottjehl/picturefill Source: http://responsiveimages.org POLYFILL
  10. Other Image Tweeks • Background-size: • Compress 2x images –

    Webp: https://developers.google.com/speed/webp/
  11. Server Side • CMS (Wordpress) • http://www.resrc.it : – Delivers

    the right image based on the screen size – Bandwidth Detection
  12. What if everyone has a HiDPI screen • Ultra High

    Definition (UHD) – 4k TVs – 8K - 7680×4320 Resolution • vw & vh units – 1 vw = 1/100 of viewport width • 2X the images everywhere ?
  13. Physical Units ? • Very hard to distinguish between devices

    – iPad 2 and iPad Mini – Phone to 7’’ tablets – 7’’ tablet to 10’’ tablet • Elements across devices are not of the same physical size – Use <button style=“width: 2inch;”> ? • Safari/Chrome does not support @media screen and (min-resolution :320dpi)
  14. To Consider for HiDPI • Eliminate Images + Use CSS3

    • Web fonts for icons • SVG • Use image-set and srcset • Use Viewport units – vw, vh
  15. Thank You • Slides: https://speakerdeck.com/artminister • Many thanks to –

    Micheal Cheng (@coderkungfu) – Hackerspace SG • Calling for speakers
  16. Other User groups and Resources • Talk.js http://www.meetup.com/Singapore-JS/events/99986652/ • Singapore

    JS https://www.facebook.com/groups/488579174512027/ • HTML5 Rocks SG http://www.meetup.com/HTML5Rocks-SG/ • Webuild – http://webuild.sg