liveBook · Manning

Feature detection

Feature detection is the practice of testing whether a runtime environment supports a particular capability.

How 3 Manning books explain it

Vanilla Web

Feature detection is a technique for determining at runtime whether a browser or environment supports a particular capability.

How it is used
Keeps a web app usable across differing browser capabilities while enabling optional features where available.
How deep it goes
Demonstrates property-presence checks for the Permissions API and file pickers, including picker constraints, without exploring browser internals.
Examples
Uses a guarded geolocation permission query and guarded file-opening and file-saving workflows.
What you can do after
Apply it via native JavaScript property checks to use supported APIs conditionally and provide a fallback.

Read how Vanilla Web explains feature detection →

HTML5 in Action

Feature detection is the technique of checking whether a software environment supports a particular capability.

How it is used
Selects browser-specific resources and fallbacks when HTML5 feature support varies.
How deep it goes
Explains feature tests and conditional loading, then applies checks to form validation, database objects, and Canvas contexts.
Examples
Uses a month-picker fallback, a localStorage polyfill, vendor-prefixed database objects, and a Canvas 2D context check.
What you can do after
Apply it via Modernizr to test support and conditionally load a fallback.

Read how HTML5 in Action explains feature detection →

Secrets of the JavaScript Ninja, Second Edition

Checking whether a runtime environment supports a capability by testing for the feature itself.

How it is used
Uses runtime capability checks to select supported APIs or fallbacks in reusable cross-browser JavaScript.
How deep it goes
Defines presence checks and works through API selection and a polyfill, while noting that existence may not guarantee implied functionality.
Examples
Uses event-handler API selection and an Array.prototype.find fallback as concrete examples.
What you can do after
Apply capability checks to choose between standard and legacy event APIs or provide an Array.find fallback.

Read how Secrets of the JavaScript Ninja, Second Edition explains feature detection →

What to know first

Related concepts

Questions about feature detection

What is feature detection?

Feature detection is the practice of testing whether a runtime environment supports a particular capability.

Which Manning books explain feature detection?

Vanilla Web, HTML5 in Action and Secrets of the JavaScript Ninja, Second Edition.

What should I know before learning feature detection?

Manning books that teach feature detection usually introduce canvas element and web standards first.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.