Polyfill (programming): Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
Alter: title. Add: date, title. Changed bare reference to CS1/2. | Use this bot. Report bugs. | Suggested by BrownHairedGirl | Linked from User:BrownHairedGirl/Articles_with_bare_links | #UCB_webform_linked 976/2195
Citation bot (talk | contribs)
Add: website. | Use this bot. Report bugs. | Suggested by Whoop whoop pull up | Category:Web browsers | #UCB_Category 114/125
Line 8:
==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.<ref name="introducing276">{{cite book |title=Introducing HTML5 |author1=Bruce Lawson |author2=Remy Sharp |section=Introducing Polyfills |pages=[https://books.google.com/books?id=a8HQCk4pbQkC&pg=PA276 276–277]}}</ref><ref name="sharp2010">{{cite web |last=Sharp |first=Remy |title=What is a polyfill? |url=http://remysharp.com/2010/10/08/what-is-a-polyfill/ |access-date=13 January 2012}}</ref> Formally, "a shim is a [[Library (computing)|library]] that brings a new API to an older environment, using only the means of that environment.",<ref name="speakingjs"/> and polyfills exactly fit this definition; the term ''shim'' was also used for early polyfills.<ref>{{cite web |quote=This piece of information makes building an HTML5 compatibility shim for IE7 far easier than had previously been assumed.|title=Mistakes, Sadness, Regret |url=http://ln.hixie.ch/?start=1201080691&count=1 |author-link=Ian Hickson |author=Ian Hickson |date=2008-01-23}}</ref> However, to Sharp ''shim'' connoted non-transparent APIs and workarounds, such as [[spacer GIF]]s for layout, sometimes known as <code>shim.gif</code>, and similar terms such as ''[[progressive enhancement]]'' and ''[[graceful degradation]]'' were not appropriate, so he invented a new term.<ref name="sharp2010"/> 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 holes (in functionality) in many ([[wikt:poly-|poly-]]) ways". The word since gained popularity, particularly due to its use by [[Paul Irish]] and in [[Modernizr]] documentation.<ref name="sharp2010"/><ref>{{cite web |url=https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills |title=HTML5 Cross browser Polyfills |website=[[GitHub]] |archive-url=https://web.archive.org/web/20100928233437/http://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills |archive-date=2010-09-28}}</ref>
 
The distinction that Sharp makes is:<ref name="introducing276"/>
Line 17:
 
=== core-js ===
core-js<ref>{{Cite web|url=https://github.com/zloirock/core-js|title = Core-js|website = [[GitHub]]|date = 26 October 2021}}</ref> is the most popular<ref>{{Cite web|url=https://www.npmtrends.com/core-js-vs-core-js-pure-vs-es5-shim-vs-es6-shim-vs-airbnb-js-shims-vs-polyfill-library-vs-polyfill-service-vs-js-polyfills|title = 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 &#124; NPM trends}}</ref> and powerful<ref>http://kangax.github.io/compat-table/es6/#babel7corejs3</ref> JavaScript [[standard library]] polyfill. Includes polyfills for [[ECMAScript]] up to 2021: promises, symbols, collections, iterators, typed arrays, many other features, ECMAScript proposals, some cross-platform [[WHATWG]] / [[W3C]] features and proposals like <code>URL</code>. You can load only required features or use it without global namespace pollution. It can be integrated with [[Babel_(compiler)|Babel]], which allows it to automatically inject required core-js modules to your code.
 
=== HTML5 Shiv ===