Polyfill (programming): Difference between revisions

Content deleted Content added
Definition: remove link to deleted article
explanation of term "shiv" no longer occurs several paragraphs before the first usage of the word.
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>{{efn|The use of the term ''shiv'' here is a pun or mistake on ''shim.''<ref name="introducing276"/>}} 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 |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 21:
=== HTML5 Shiv ===
 
In IE versions prior to 9, unknown HTML elements like {{tag|section|o}} and {{tag|nav|o}} 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{{efn|The use of the term ''shiv'' here is a pun or mistake on ''shim.''<ref name="introducing276"/>}}, exploits another quirk of IE to work around this bug: calling <code>document.createElement("tagname")</code> for each of the new HTML5 elements, which causes IE to parse them correctly. It also includes basic default styling for those HTML5 elements.
 
=== -prefix-free ===