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

Progressive Enhancement Revisited

Progressive Enhancement Revisited

A refreshment / re-assertion of progressive enhancement principles, with some philosophy and anecdotal examples thrown in. Given at BelfastJS in 2016. I got a job.

Neil McCallion

August 24, 2016
Tweet

More Decks by Neil McCallion

Other Decks in Programming

Transcript

  1. Copyright 2005-2016 rehabstudio - All Rights Reserved. Neil McCallion Head

    of Front-End Development, +rehabstudio codepen.io/njmcode github.com/njmcode njmcode.github.io @njmcode rehabstudio.com GIZ’ A JOB
  2. Copyright 2005-2016 rehabstudio - All Rights Reserved. Progressive enhancement Performance

    Robustness User experience Accessibility PE is the art of starting with the basics and adding complexity on top. If the upper layers fail, the core layer will still work.
  3. Copyright 2005-2016 rehabstudio - All Rights Reserved. Good Bad As

    a user, I want to get to the next floor... A set of stairs, enhanced with motion. I can walk up the stairs even if there’s no motion. A metal box, enhanced with motion. If there’s no motion, I’m just standing in a box.
  4. Copyright 2005-2016 rehabstudio - All Rights Reserved. This is a

    diagram slide Progressive enhancement goals: - Respond to the user ASAP - Improve perceived performance - Avoid white screen of death - Remain useful even under stress / error conditions - Improve reach / user base
  5. Copyright 2005-2016 rehabstudio - All Rights Reserved. Performance The mobile

    web is the primary means of consumption for many internet users - intermittent signal, limited bandwidth, emerging markets. etc.
  6. Copyright 2005-2016 rehabstudio - All Rights Reserved. Performance Slack renders

    an ‘app shell’ immediately before loading the JS app, so the user isn’t staring at a white screen while waiting for the rest of the experience to arrive.
  7. Copyright 2005-2016 rehabstudio - All Rights Reserved. This is a

    diagram slide <style> /* Critical styling for app shell */ .sidebar { ... } .main { ... } </style> <body> <div class="app"> <!-- App shell HTML --> <div class="sidebar">Loading…</div> <div class="main">Witty quote…</div> </div> <script src="app.js"></script> <script> // Kicks off the app, rendering into the shell App.start(); </script> </body>
  8. Copyright 2005-2016 rehabstudio - All Rights Reserved. Robustness Your application

    JS could fail to load and/or execute for many reasons. It’s not safe to assume that users will receive the JavaScript even if they have it turned on. <noscript> != <crap-connection> <js-error> <cdn-failure> <firewall>
  9. Copyright 2005-2016 rehabstudio - All Rights Reserved. Robustness Render something

    meaningful from the server wherever possible, without relying on the JS app to display initial content. E.g. a weather app could render the current weather for the day based on the user’s IP address, and enhance with geolocation once the JS has loaded. You may not be able to replicate full functionality on the server, and in many cases you shouldn’t try, but think of what core information you could display on first render and try to send it with the initial HTML payload.
  10. Copyright 2005-2016 rehabstudio - All Rights Reserved. Fully functional JS

    app vs Somewhat useful HTML render vs White screen of death
  11. Copyright 2005-2016 rehabstudio - All Rights Reserved. This is a

    diagram slide If you *must* have a scroll-to-section feature in your app, make sure you set it up with basic #anchor links first! If the JS fails, the browser will still be able to jump to the anchor directly. Core functionality: ‘take me to the content’. Enhanced functionality: ‘Smooth scroll to the content’.
  12. Copyright 2005-2016 rehabstudio - All Rights Reserved. This is a

    diagram slide Always set base colours for backgrounds, buttons etc, in case graphic assets fail to load.
  13. Copyright 2005-2016 rehabstudio - All Rights Reserved. This is a

    diagram slide If you have a dropdown nav which relies on JS, have the nav visible by default, and close it once the JS loads. Otherwise, if the JS fails, you’ll have an invisible navigation and no way to open it.
  14. Copyright 2005-2016 rehabstudio - All Rights Reserved. Carousels, tabs and

    accordions are just a collapsed list of <div>s with some styling and logic applied. If the JS fails, the content is still present and readable. Use #anchor tags to preserve the basic functionality of the tabs/pagination. 1 2 3 1 | 2 | 3 1 2 3 1 | 2 | 3 1 | 2 | 3 1
  15. Copyright 2005-2016 rehabstudio - All Rights Reserved. This is a

    diagram slide Progressive enhancement goals: - Respond to the user ASAP - Improve perceived performance - Avoid white screen of death - Remain useful even under stress / error conditions - Improve reach / user base
  16. Copyright 2005-2016 rehabstudio - All Rights Reserved. Always *think* progressive

    enhancement What is your critical content / feature? Easy wins for performance and legacy support Put the user’s needs first Make the mobile web a friendlier place