liveBook · Manning

Polyfill

A polyfill is a compatibility implementation that supplies a platform or language feature missing from an execution environment.

How 2 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 →

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.