e01.org

Polyfill (programming)

In software development, a polyfill is code that implements a new standard feature of a deployment environment within an old version of that environment that does not natively support the feature. Most often, it refers to JavaScript or WebAssembly code that implements an HTML5 or CSS web standard, either an established standard (supported by some browsers) on older browsers, or a proposed standard (not supported by any browsers) on existing browsers. Polyfills are also used in PHP and Python. Polyfills allow web developers to use an API regardless of whether or not it is supported by a browser, and usually with minimal overhead. Typically they first check if a browser supports an API, and use it if available, otherwise using their own implementation. Polyfills themselves use other, more supported features, and thus different polyfills may be needed for different browsers. The term is also used as a verb: polyfilling is providing a polyfill for a feature.

In software development, a polyfill is code that implements a new standard feature of a deployment environment within an old version of that environment that does not natively support the feature. Most often, it refers to JavaScript or WebAssembly code that implements an HTML5 or CSS web standard, either an established standard (supported by some browsers) on older browsers, or a proposed standard (not supported by any browsers) on existing browsers. Polyfills are also used in PHP and Python. Polyfills allow web developers to use an API regardless of whether or not it is supported by a browser, and usually with minimal overhead. Typically they first check if a browser supports an API, and use it if available, otherwise using their own implementation. Polyfills themselves use other, more supported features, and thus different polyfills may be needed for different browsers. The term is also used as a verb: polyfilling is providing a polyfill for a feature. ==Definition== The term is a neologism, coined by Remy Sharp, who required a word that meant "replicate an API using JavaScript (or Flash or whatever) if the browser doesn’t have it natively" while co-writing the book Introducing HTML5 in 2009. Formally, "a shim is a library that brings a new API to an older environment, using only the means of that environment." Polyfills exactly fit this definition; the term shim was also used for early polyfills. However, to Sharp shim connoted non-transparent APIs and workarounds, such as spacer GIFs for layout, sometimes known as shim.gif , and similar terms such as progressive enhancement and graceful degradation were not appropriate, so he invented a new term. The term is based on the multipurpose filling paste brand Polyfilla, a paste used to cover up cracks and holes in walls, and the meaning "fill in holes (in functionality) in many (poly-) ways." The word has since gained popularity, particularly due to its use by Paul Irish and in Modernizr documentation. The distinction that Sharp makes is: This distinction is not drawn by other authors. At times various other distinctions are drawn between shims, polyfills, and fallbacks, but there are no generally accepted distinctions: most consider polyfills a form of shim. The term polyfiller is also occasionally found. ===html5shiv=== In IE versions prior to 9, unknown HTML elements like and would be parsed as empty elements, breaking the page's nesting structure and making those elements impossible to style using CSS. One of the most widely used polyfills, html5shiv, exploits another quirk of IE to work around this bug: calling document.createElement("tagname") for each of the new HTML5 elements, which causes IE to parse them correctly. It also includes basic default styling for those HTML5 elements. Though most polyfills target out-of-date browsers, some exist to simply push modern browsers forward a little bit more. Lea Verou's -prefix-free polyfill is such a polyfill, allowing current browsers to recognise the unprefixed versions of several CSS3 properties instead of requiring the developer to write out all the vendor prefixes. It reads the page's stylesheets and replaces any unprefixed properties with their prefixed counterparts recognised by the current browser. ==Notes== ==References==

References

  1. ^ Thormeier, Pascal (9 June 2023). Mastering CSS Grid: A comprehensive and practical guide to creating beautiful layouts with CSS Grid . Packt Publishing Ltd. p. 195. ISBN 978-1-80461-616-1 . Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  2. ^ "Core-js" . GitHub . 26 October 2021. Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  3. ^ "Airbnb-js-shims vs core-js vs core-js-pure vs es5-shim vs es6-shim vs js-polyfills vs polyfill-library vs polyfill-service | NPM trends" . Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  4. ^ The use of the term shiv here is a pun or mistake on shim. [ 4 ] Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  5. ^ Goodin, Dan (3 July 2024). "384,000 sites pull code from sketchy code library recently bought by Chinese firm" . Ars Technica . Retrieved 3 July 2024 . Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  6. ^ Mudaliar, Anuj (27 June 2024). "Polyfill.io Attack Infects Over 110,000 Websites" . Spiceworks . Retrieved 1 July 2024 . Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  7. ^ Stănciulescu, Adelaida (2025). "The Web Ecosystem Between Vulnerability and Resilience: The Case of Polyfill.io" . Proceedings of the International Conference on Cybersecurity and Cybercrime . 12 : 74– 82. doi : 10.19107/cybercon.2025.08 . Wikidata Q140428929 . Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  8. ^ "navigator.id" . Mozilla Developer Network. 30 June 2012. Archived from the original on 3 August 2012 . Retrieved 9 July 2012 . Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  9. ^ "Hyphenopoly.js" . GitHub . 25 September 2022. Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  10. ^ "It typically checks if a browser supports an API. If it doesn’t, the polyfill installs its own implementation. That allows you to use the API in either case." Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  11. ^ Ian Hickson (23 January 2008). "Mistakes, Sadness, Regret" . This piece of information makes building an HTML5 compatibility shim for IE7 far easier than had previously been assumed. Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  12. ^ "HTML5 Cross browser Polyfills" . GitHub . Archived from the original on 28 September 2010. Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  13. ^ "What is the difference between a shim and a polyfill?" . Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  14. ^ Chuck Hudson; Tom Leadbetter (2011). HTML5 Developer's Cookbook . Addison–Wesley. p. 121. ISBN 978-0-132-69732-3 . Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  15. ^ a b c Lawson, Bruce; Sharp, Remy (2011). "Introducing Polyfills" . Introducing HTML5 (2nd ed.). New Riders Publishing. pp. 276– 277. ISBN 978-0-13-279297-4 . OCLC 1338838664 . OL 35570116M . Wikidata Q140427577 . Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  16. ^ a b c Sharp, Remy (8 October 2010). "What is a polyfill?" . Retrieved 13 January 2012 . Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  17. ^ a b c Luis Ángel Pérez Castillo (2019). Speaking JavaScript . Wikipedia revision 1366794961, retrieved 2026-11-20 · 1795129200.0
  18. Mastering CSS Grid: A comprehensive and practical guide to creating beauti . · 1785366000.0
  19. Airbnb-js-shims vs core-js v . · 1785366000.0
  20. exploits another quirk of IE to work around this bug: calling document.createElement("tagname") for each of the new HTML5 elements, which causes IE to parse them correctly. It also includes basic d . · 1785366000.0
  21. Polyfill.io Attack Infects Over 110,000 Websites . · 1785366000.0
  22. navigator.id . Mozilla Developer Network . 30 June 2012. retrieved 9 July 2012 · 1785366000.0
  23. Hyphenopoly.js . GitHub . 25 September 2022. · 1785366000.0
  24. Luis Ángel Pérez Castillo. Speaking JavaScript . 2019. · 1785366000.0
  25. books.google.com . · 1785366000.0
  26. Sharp, Remy. What is a polyfill? . 8 October 2010. retrieved 13 January 2012 · 1785366000.0
  27. Polyfills exactly fit this definition; the term shim was also used for early polyfills. cite web |quote=This piece of information makes building an HTML5 compatibility shim for IE7 far easier th . · 1785366000.0
  28. The term is based on the spackling paste|multipurpose filling paste brand Spackling paste#Polyfilla|Polyfilla, a paste used to cover up cracks and holes in walls, and the meaning "fill in . · 1785366000.0
  29. blockquote|What makes a polyfill different from the techniques we have already, like a shim, is this: if you removed the polyfill script, your code would continue to work, without any changes requir . · 1785366000.0
  30. HTML5 Developer's Cookbook . Addison–Wesley . 2011. · 1785366000.0
  31. Core-js . GitHub . 26 October 2021. · 1785366000.0
source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Polyfill (programming)". 1785390182. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1366794961

JSON record · API collection · citation policy