|
| 1 | +--- |
| 2 | +title: Polyfills |
| 3 | +slug: MDN/Writing_guidelines/Page_structures/Polyfills |
| 4 | +page-type: mdn-writing-guide |
| 5 | +sidebar: mdnsidebar |
| 6 | +--- |
| 7 | + |
| 8 | +This page outlines MDN's policy for including polyfills in the reference documentation for [JavaScript](/en-US/docs/Web/JavaScript) and [Web APIs](/en-US/docs/Web/API). |
| 9 | + |
| 10 | +A {{glossary("Polyfill", "polyfill")}} is an implementation of a web platform feature that websites can use in browsers that do not natively support the feature. Polyfills enable web developers to write a single codebase targeting multiple browsers and browser versions, even when some of those browsers don't support some of the features used. |
| 11 | + |
| 12 | +Polyfills are important to web developers but are also a risk: buggy polyfills can break websites or create security vulnerabilities. For this reason, MDN recommends specific sources for polyfills, and is very conservative about adding additional sources. |
| 13 | + |
| 14 | +## Polyfills in the JavaScript reference |
| 15 | + |
| 16 | +### Selected polyfills |
| 17 | + |
| 18 | +The [JavaScript reference documentation](/en-US/docs/Web/JavaScript) can link to polyfills from two sources: |
| 19 | + |
| 20 | +- The [core-js](https://github.com/zloirock/core-js/tree/master) library. |
| 21 | +- The [es-shims](https://github.com/es-shims) organization. |
| 22 | + |
| 23 | +Sources are selected by the MDN maintainers based on the following criteria: |
| 24 | + |
| 25 | +- Conformance to the specification for the feature for which they are providing an implementation. |
| 26 | +- Adoption by the web development community, as seen in metrics such as the number of [npm](https://www.npmjs.com/) downloads. |
| 27 | + |
| 28 | +### Proposing an additional polyfill source |
| 29 | + |
| 30 | +Anyone can propose that MDN should recognize an additional source of polyfills by [starting a discussion in the MDN discussion forum](https://github.com/orgs/mdn/discussions). However, the MDN maintainers expect the number of recognized polyfills linked from MDN to remain very small, to reduce the risk of recommending polyfills that cause problems for web developers. |
| 31 | + |
| 32 | +### Integration of polyfills into pages |
| 33 | + |
| 34 | +When a page in the JavaScript reference documentation links to a polyfill, it adds the link in the "See also" section at the end of the page. |
| 35 | + |
| 36 | +The link is placed at the start of the "See also" list, in the following format: |
| 37 | + |
| 38 | +```md |
| 39 | +- [Polyfill for `featureName` in `project-name`](link) |
| 40 | +``` |
| 41 | + |
| 42 | +## Polyfills in the Web API reference |
| 43 | + |
| 44 | +### Selected polyfills |
| 45 | + |
| 46 | +The [Web API reference documentation](/en-US/docs/Web/API) can link to polyfills that are maintained alongside the specification for the feature itself. |
| 47 | + |
| 48 | +For example, the [Trusted Types API](/en-US/docs/Web/API/Trusted_Types_API) has a polyfill which is [maintained in the same repository as the specification](https://github.com/w3c/trusted-types?tab=readme-ov-file#polyfill). Accordingly, the Trusted Types API reference documentation on MDN can link to that polyfill. |
| 49 | + |
| 50 | +### Integration of polyfills into pages |
| 51 | + |
| 52 | +Polyfills are typically integrated into the [overview page for the API](/en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/Page_type_key#web_api_page_types). |
0 commit comments