Polyfill
A polyfill is code that provides a compatible implementation of a platform or language feature missing from an execution environment.
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.
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.
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 →
Also covered in
- Fast by DefaultIn early access (MEAP)
- Vanilla WebIn early access (MEAP)
- Essential TypeScript 5, Third Edition
- Pro Angular 16
- Modern Angular
- Secrets of the JavaScript Ninja, Third EditionIn early access (MEAP)
What to know first
- JavaScriptJavaScript is a high-level, dynamically typed programming language standardized as ECMAScript and used for web and general-purpose programming.
- backward compatibilityBackward compatibility is the property of a changed or newer system remaining usable by existing clients, code, data, or integrations that rely on earlier interfaces or behavior.
- CSSCSS (Cascading Style Sheets) is a stylesheet language for specifying the presentation and layout of structured documents.
- Document Object ModelThe Document Object Model is a platform-independent programming interface that represents a document as a structured tree of nodes and provides ways to access and modify its content and structure.
Related concepts
- Custom Elementsimplements · A custom element is an author-defined HTML element that represents application-specific content or behavior beyond that of built-in HTML elements.
- feature detectionused by · Feature detection is the practice of testing whether a runtime environment supports a particular capability.
- findimplements · A find operation searches a collection for the first element or entry matching a value or predicate and returns it, or indicates that no match exists.
- Mapimplements · A map is an associative data structure that stores key-value associations and supports retrieving values by key.
- requestAnimationFrameimplements · requestAnimationFrame is a browser API method that schedules a callback to run before the next visual rendering update.
Questions about polyfill
What is polyfill?
A polyfill is code that provides a compatible implementation of a platform or language feature missing from an execution environment.
Which Manning books explain polyfill?
Web Components in Action, HTML5 in Action and Secrets of the JavaScript Ninja, Second Edition.
What should I know before learning polyfill?
Manning books that teach polyfill usually introduce JavaScript, backward compatibility, CSS and Document Object Model 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.


