275 The HTML5 platform [1.5d]

Updated . Posted . Visible to the public.

Browsers differ in which HTML, CSS and JavaScript features they support. This lesson covers how to find out what you can use, which browsers we support, and how transpilation, polyfills and graceful degradation help.

Important

Work on this lesson in advisor mode.

Learning goals

  • You can explain why browsers differ in feature support and look up whether a feature is safe to use, e.g. on Can I Use or MDN.
  • You know which browsers we support in a typical project, and why an app with a closed user group can support fewer.
  • You can explain what an evergreen browser is and why Safari, especially on iOS, lags behind the others.
  • You can explain the difference between transpiling and polyfilling, and which features neither can provide.
  • You can degrade gracefully when a feature may be missing β€” detect it and fall back β€” in HTML, CSS and JavaScript.
  • You can test an app in browsers and devices you don't own, e.g. on BrowserStack, including mobile browsers.
  • You can recognize outdated advice β€” Internet Explorer workarounds, transpiling to ES5 β€” and ignore it.

Resources

Read what's new to you, skim what's familiar, skip what you already master. Stop when you can meet the learning goals.

Your agent can also generate an overview, a tutorial or an explanation for anything here, tailored to what you already know. Just ask.

Exercises

Debugging old browsers

Use BrowserStack to view your MovieDB app in an older Safari version. Use increasingly older Safari versions until something breaks in your JavaScript or CSS.

Can you find out what missing feature is causing your app to break?

Tip

BrowserStack lets you open the developer tools within the remote computer.

Graceful degradation

Use the Web Share API Show archive.org snapshot to implement a share button on each movie's show view.

When the user presses the show button on a mobile phone, the phone's native share target selection should open. The share target selection allows me to pick a target app like WhatsApp, GMail, or Slack. When the user picks e.g. WhatsApp a text like this should be shared:

Check out "Sunshine" from 2007: https://moviedb/movies/123

When the current browser doesn't support the share() function, the user should instead see the shareable text in a prompt Show archive.org snapshot from where they can copy & paste the text manually.

Tip

The Web Share API only works for https:// URLs. You can enable HTTPS for development.

Write your own polyfill

Write a Polyfill for NodeList#forEach Show archive.org snapshot . It should only be applied to browsers that don't implement it Show archive.org snapshot , for example IE11 or Chrome 50 in BrowserStack.

You don't need to implement the thisArg part of the Spec.

Profile picture of Henning Koch
Henning Koch
Last edit
Michael LeimstΓ€dtner
Keywords
html5
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra Curriculum (2015-07-08 18:02)