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

When Responsive Design Meets the Real World

Jason Grigsby
September 24, 2013

When Responsive Design Meets the Real World

Presented at Mobile Portland, September 23, 2013

Jason Grigsby

September 24, 2013
Tweet

More Decks by Jason Grigsby

Other Decks in Technology

Transcript

  1. 80% during misc downtime 76% while waiting in lines 86%

    while watching TV 69% for point of sale research http://www.flickr.com/photos/missmeng/5327470961
  2. TMI

  3. Log In Subscribe Basket Contact Us i am looking for...

    67% of consumers cite slow websites as the main cause of basket abandonment Daily Pulse Newsletter Get our free Daily Pulse Newsletter to keep informed about the latest news and insights in Digital Marketing. Register for our free Daily Pulse ADVERTISE HERE » by David Moth 06 December 2012 11:40 8 comments Print Tweet Tweet 236 3 Everyone hates slow loading websites, and a new survey highlights just how damaging a slow site can be to the user experience. The study by Brand Perfect found that two thirds of UK consumers (67%) cite slow loading times as the main reason they would abandon an online purchase. It’s a topic we’ve looked at in more detail in our post 'Site speed: case studies, tips and tools for improving your conversion rate', with stats showing that slow loading websites are losing businesses up to £1.73bn a year. Privacy and cookie policy Home / Blog Subscribe Reports Training Events Jobs Blog More Browse by topic Like 14 Share Share 20 Slow sites mean real dollars are lost.
  4. 2 CORE GESTURES CORE GESTURES CORE GESTURES CORE GESTURES CORE

    GESTURES CORE GESTURES CORE GESTURES CORE GESTURES Tap )YPLÅ`[V\JOZ\YMHJL^P[OÄUNLY[PW Pinch ;V\JOZ\YMHJL^P[O[^VÄUNLYZHUKIYPUN them closer together. Double Tap 9HWPKS`[V\JOZ\YMHJL[^PJL^P[OÄUNLY[PW Spread ;V\JOZ\YMHJL^P[O[^VÄUNLYZHUKTV]L them apart. Drag 4V]LÄUNLY[PWV]LYZ\YMHJL^P[OV\[SVZPUN contact. Press Touch surface for extended period of time. Flick 8\PJRS`IY\ZOZ\YMHJL^P[OÄUNLY[PW Press+ Tap 7YLZZZ\YMHJL^P[OVULÄUNLYHUKIYPLÅ` [V\JOZ\YMHJL^P[OZLJVUKÄUNLY Mobile browsers offer many ways to navigate desktop web sites. Luke’s fantastic gesture reference: http://www.lukew.com/ff/entry.asp?1071
  5. Original Resized K Saved % Saved Holmes 34.7K 8.1K 26.6K

    76.6% Watson 39.0K 8.4K 30.6K 78.4% Mycroft 30.5K 6.7K 23.8K 78.0% Moriarty 43.4K 8.2K 35.2K 81.1% Adler 26.0K 6.6K 19.4K 74.6% Winter 34.7K 7.8K 26.9K 77.5% Total 208.3K 45.8K 162.5K 78.0% Media Queries Hide Problems
  6. 9% 4% 21% 38% 4% 25% Mobile is Larger Same

    Size Less than 10% Savings 11 to 50% Savings 51% to 100% Savings Greater than 100% Savings Where are the Mobile First RWDs? 106 sites from mediaqueri.es tested http://blog.cloudfour.com/where-are-the-mobile-first-responsive-web-designs/
  7. Growth Constraints Capabilities Opportunity Focus Innovation = = = Luke’s

    Take on Mobile First http://www.lukew.com/ff/entry.asp?933
  8. This is why Mobile First thinking is so powerful even

    on projects that are currently implemented on the desktop. Mobile First
  9. /* Wider viewports/higher resolutions (e.g. desktop) */ @media screen and

    (min-width:481px) { [Desktop layout rules here] } /* Mobile/lower-resolution devices */ @media screen and (max-width:480px) { [Mobile layout rules here] } Move the mobile media query block above the desktop media query. By doing this, we’re making sure the cascading effect of CSS is consistent with our mobile first progressive enhancement approach. Reorder media queries so cascade goes from small to large screens Keep basic styles outside of media queries.
  10. The absence of support for media queries is in fact

    the first media query. —Bryan Rieger, Yiibu
  11. Oh come on IE. No love? Because IE 8 and

    below don’t support media queries, IE isn’t getting the CSS rules that create columns.
  12. <link rel="stylesheet" type="text/css" href="taps.css" /> <link rel="stylesheet" type="text/css" href="layout.css" media="all

    and (min-width: 481px)"> <!--[if (lt IE 9)&(!IEMobile)]> <link rel="stylesheet" type="text/css" href="layout.css" media="all" /> <![endif]--> The conditional comment repeats the line above it ensuring desktop IE sees our layout.css file. IE conditional comments
  13. <link rel="stylesheet" type="text/css" href="taps.css" /> <link rel="stylesheet" type="text/css" href="layout.css" media="all

    and (min-width: 481px)"> <!--[if (lt IE 9)&(!IEMobile)]> <link rel="stylesheet" type="text/css" href="layout.css" media="all" /> <![endif]--> The conditional comment repeats the line above it ensuring desktop IE sees our layout.css file. IE conditional comments or use Respond.js (a media query polyfill for IE)
  14. The taps.jpg file is 440.7K making it the largest file

    on the page. @media screen and (max-width:480px) { [Other CSS rules are here] .header {display:none;} } Images with display:none are still downloaded
  15. <div%id="test5"></div> @media%all%and%(min4width:%601px)%{ %%%%#test5%{ %%%%%%%%background4image:url('images/test54desktop.png'); %%%%%%%%width:200px; %%%%%%%%height:75px; %%%%} } @media%all%and%(max4width:%600px)%{ %%%%#test5%{

    %%%%%%%%background4image:url('images/test54mobile.png'); %%%%%%%%width:200px; %%%%%%%%height:75px; %%%%} } Images scoped within media queries http://timkadlec.com/2012/04/media-query-asset-downloading-results/
  16. Conditionally load JS based on screen size and capabilities #3

    http://www.flickr.com/photos/lyza/7382255242/
  17. <iframe id="map" width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com..."></iframe> Extremely

    long URL abbreviated This single iframe causes 47 files to be downloaded! Look inside ontap.html to find this code. @media screen and (max-width:480px) { . . . #map {display:none;} } taps.css There are many more rules in the css file. The iframe has an id of map. This rule hides the Google Maps iframe by setting the display to none. Hiding content with display:none does not prevent it from downloading.
  18. One SRC to rule all images <img src="brews_images/bensons_bubbler.jpg" alt="Bensons Bubbler">

    There are 16 beer labels on the On Tap Now page that use an img tag like this one for the Bensons Bubbler. Despite the need for multiple versions of this image depending on the screen size, HTML only allows one value for the src.
  19. Art direction: Images with text Sign In Account Get Email

    Español Shopping Bag Features New Arrivals Show Off Tees Backpacks Tech Toys 2/$30 & 2/$40 PINK Favorites Spin the Panty Wheel Tops All Tops Hoodies & Crews Tees & Tanks Bottoms All Bottoms Sweats Shorts Yoga PINK Loves Yoga Panties 5/$26 Styles 3/$33 Styles Shop by Style Bras All Bras Bandeaus & Bralettes 2/$42 Wear Everywhere Bras Bras 101 Swim Search
  20. Things are still moving forward on a standards-based approach for

    responsive images. http://www.flickr.com/photos/johnlamb/2576062549/
  21. <div data-picture data-alt="A giant stone face at The Bayon temple

    in Angkor Thom, Cambodia"> <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. --> <noscript> <img src="small.jpg" alt="A giant stone face at The Bayon temple in Angkor Thom, Cambodia"> </noscript> </div> Picturefill JavaScript Library https://github.com/scottjehl/picturefill
  22. Image Resolution 0 500000 1000000 1500000 2000000 Blackberry Curve iPhone

    iPhone Retina Macbook Macbook Retina 1861632 465408 519360 130080 57920 320x181 480x271 960x541 909x512 1818x1024
  23. Image Resolution 3,214% bigger 0 500000 1000000 1500000 2000000 Blackberry

    Curve iPhone iPhone Retina Macbook Macbook Retina 1861632 465408 519360 130080 57920 320x181 480x271 960x541 909x512 1818x1024
  24. 0 50 100 150 200 Blackberry Curve iPhone iPhone Retina

    Macbook Macbook Retina 172 80 63 22 12 JPEG Compressed (k)
  25. 0 50 100 150 200 Blackberry Curve iPhone iPhone Retina

    Macbook Macbook Retina 172 80 63 22 12 JPEG Compressed (k) 1,433% bigger
  26. 0 1500 3000 4500 6000 Blackberry Curve iPhone iPhone Retina

    Macbook Macbook Retina 5,478 1,362 1,526 381 170 JPEG Uncompressed (k)
  27. 0 1500 3000 4500 6000 Blackberry Curve iPhone iPhone Retina

    Macbook Macbook Retina 5,478 1,362 1,526 381 170 JPEG Uncompressed (k) 3,211% bigger
  28. Apple.com as an anti-pattern Downloads both standard and retina images

    The total size of the page goes from 502.90K to 2.13MB when the retina versions of images are downloaded. http://blog.cloudfour.com/how-apple-com-will-serve-retina-images-to-new-ipads/
  29. <style> #main { background-size: 400px 250px; } @media screen and

    (-webkit-device-pixel-ratio: 1) { /* Image for normal displays. */ #main { background-image: url(dog.jpg); } } @media screen and (-webkit-min-device-pixel-ratio: 2) { /* Image for high resolution displays. */ #main { background-image: (dog-hi-res.jpg); } } </style> If possible, use CSS for now
  30. IcoMoon App Premium Icons Font CDN Browse 3800+ Free Vector

    Icons Import Your Own Vectors to Make Fonts Generate Custom & Crisp Icon Fonts Generate CSS Sprites with any size or color Basic Glyph Editing 1200+ Vector Icons & Counting Handcrafted on a 16×16 grid Several Different Formats Optimized for Icon Fonts Free Updates Serve Custom-Built Fonts Powered by Amazon Web Services Easily Update Your Icon Fonts Production (Cached) Links Starting at $1.60/Month IcoMoon IcoMoon Custom Built and Crisp Icon Fonts, Done Right Home App Icon Packs Font CDN Demo Documentation Blog About
  31. Topics: announcements css icon design progressive enhancement Grunticon: A Grunt.js

    plugin for managing and delivering sharp icons to all devices Posted by Scott on 08/31/2012 Note: Grunticon was formerly named Unicon. The name was changed on September 19, 2012. Creating sharp-looking icons and background images in our client work has always been more complicated than we want it to be, and with the growing popularity of higher-definition screens, it's only getting harder. CSS sprites have traditionally worked alright, but they can be a pain to manage, are often difficult to use in CSS layouts, and require generating and serving multiple fixed-pixel sizes. Icon fonts are a nice too, but they cause problems in some of the popular mobile environments we need to support, they aren't What we do What we've done What we're thinking Who we are
  32. Images can be resized to any size with URL parameters

    #4 Provides a flexible service. Model on Sencha. Define height, width or both. <img src="http://src.sencha.io/320/http://sencha.com/files/u.jpg" alt="My constrained image" />
  33. Time Saving Content Delivery for the Team Time Saving Content

    Delivery for the Team Dynamically generate images from Photoshop, Illustrator, SVG and high-quality source files. We make it easier to manage production assets, all while serving files from a fast content delivery network. Image Optimization Image Optimization Reduce image file sizes while maintaining quality and change output formats. Dynamic Images Dynamic Images Resize, crop and encode to different image formats on- demand. API API Use our simple API to easily upload and manage files. Easily manage images and other static assets Easily manage images and other static assets Give each team member individual permission to manage specific tasks within the system. Easily spread the workload to manage assets. Sign Up Sign Up Docs Docs API API Account Account CDN Connect CDN Connect beta Features Features Projects Projects
  34. Provide automated output of PictureFill or alternative #5 <div data-picture

    data-alt="A giant stone face at The Bayon temple in Angkor Thom, Cambodia"> <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. --> <noscript> <img src="small.jpg" alt="A giant stone face at The Bayon temple in Angkor Thom, Cambodia"> </noscript> </div>
  35. { "source":"/source.jpg", "breakpoints":%[ {%"max4width":"30em","pixel4density":1,"width":360px},% {%"max4width":"30em","pixel4density":2,"width":720px}, {%"max4width":"30em","pixel4density":1,"width":800px}, {%"max4width":"30em","pixel4density":2,"width":1600px}, {%"pixel4density":1,"width":800px}, {%"pixel4density":2,"width":1600px}, ]

    } templates contain breakpoint information Responsive Images Markup Function Responsive Images Markup Function PictureFill%Markup Sample syntax. Don’t get hung up on details. Markup for all images can be changed in one spot.
  36. Integrate image compression best practices #7 jpegtran or jpegoptim OptiPNG

    or PNGOUT far future expires headers learn from mod_pagespeed or use it
  37. Bonus: Detect support for WebP image format and use it

    #8 The average WebP file size is 25% - 34% smaller compared to JPEG file size. WebP compresses 34% better than libpng, and 26% better than pngout for loseless images.
  38. Plan for the fact that it will be deprecated. Make

    it easy to change. The only rule for your responsive images implementation. #!
  39. Unlikely responsive design will ever be as fast as something

    crafted http://www.flickr.com/photos/quarenta/3256329577
  40. Flickr: Uploaded February 11, 2007 by hawridger For most projects,

    responsive design can be fast enough to make sense…
  41. Thank You! Special thanks to Scott Jehl, Guy Podjarny, and

    all of the Flickr users sharing under creative commons.