liveBook · Manning

Progressive enhancement

As explained in Vanilla Web

Progressive enhancement is an approach that starts with broadly compatible baseline functionality and adds capabilities when supported by the user's device and browser.

Progressive enhancement starts with functionality that works across a broad range of browsers and devices, then adds capabilities where they are supported. Browser versions, available APIs, and user permissions vary; a feature should not make the rest of an application unusable when it is absent. section 2.2 section 2.1.3

Make each enhancement an optional layer:

  • Establish the baseline behavior first, then detect the specific API before using it. Check compatibility data with MDN, Can I Use, or Baseline when deciding whether a fallback is needed. section 2.2.1
  • Keep ordinary navigation available. Real links can work without JavaScript; client-side routing may add soft transitions, focus restoration, and dynamic titles. section 15.12
  • Handle unavailable or denied permissions as well as unsupported APIs. Request access when it is needed, explain why, and retain a reduced but working mode if access is denied. section 2.1.3

An optional route animation

A route change needs to replace the current view; animation is not required for routing. If document.startViewTransition is available, wrap that replacement in a transition. Otherwise, perform the same replacement directly. Animation CSS can also respect prefers-reduced-motion. section 11.3.1

Listing 11.1 Wrapping a route update in a same-document view transition
if ("startViewTransition" in document) {
  document.startViewTransition(() => {
    outlet.replaceChildren(nextView);
  });
} else {
  outlet.replaceChildren(nextView);
}

The two branches perform the same route update, with a transition only when the API exists. section 11.3.1

The same decision applies beyond animation. A 3D view can select an available model display option while retaining a fallback; a router can use the Navigation API with a History API fallback. The rule is to preserve the feature’s job while allowing supported devices to do more. section 3.6.3 section 11.4

How Vanilla Web covers it

How deep it goes
Gives implementation patterns for feature detection and fallbacks, including an optional route animation; it does not prescribe one universal fallback.
Examples
Uses a Permissions API availability check, a route update with and without animation, and alternative 3D viewing options.
What it assumes
Assumes familiarity with JavaScript and browser APIs while defining the design pattern and demonstrating individual capability checks.
What you can do after
Apply it via native browser APIs to keep baseline navigation working while adding supported routing and animation capabilities.
How it connects
Connects feature detection, browser compatibility data, permissions, client-side routing, and the View Transitions API.

Also explained in

Compare how 3 books explain progressive enhancement →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vanilla Web. The section links point to the parts of the book it draws on.