liveBook · Manning

Polyfill

A polyfill is code that provides a compatible implementation of a platform or language feature missing from an execution environment.

How 3 Manning books explain it

Web Components in Action

A compatibility implementation that provides a newer web platform feature in environments lacking native support.

How it is used
Bridges missing Web Components support while prompting a feature-by-feature choice between a polyfill and a fallback.
How deep it goes
Shows script inclusion and a conditional Shadow DOM fallback, while distinguishing easy DOM polyfilling from harder CSS encapsulation.
Examples
Uses a Custom Elements CDN script, an HTML Imports page, and a component that switches between shadow and light DOM.
What you can do after
Apply it via custom-elements or webcomponentsjs, and evaluate when Shadow DOM limitations call for a non-shadow fallback.

Read how Web Components in Action explains polyfill →

HTML5 in Action

A polyfill is code that supplies an implementation of a web platform feature in an environment that lacks native support for it.

How it is used
Provides backward compatibility for HTML5 form features when browsers lack native support.
How deep it goes
Defines polyfills and walks through feature detection and conditional loading with Modernizr.
Examples
Uses a localStorage loading test and an order form’s month-picker fallback.
What you can do after
Apply it via Modernizr to conditionally load a fallback for an unsupported browser feature.

Read how HTML5 in Action explains polyfill →

Secrets of the JavaScript Ninja, Second Edition

A polyfill is code that implements a feature in environments that do not natively support it, emulating the missing behavior.

How it is used
Provides missing browser functionality as part of a cross-browser strategy.
How deep it goes
Works through feature detection and an Array.prototype.find implementation, including predicate checks and array iteration.
Examples
Demonstrates an Array.prototype.find polyfill that checks for native support and searches array values with a predicate.
What you can do after
Build a fallback implementation for Array.prototype.find when a browser lacks native support.

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

Related concepts

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.