Front-end "argot" polyfill

Original link: https://www.mk2048.com/blog/blog.php?id=h0cikjiihkib&title=%E5%89%8D%E7%AB%AF%E2%80%9C%E9%BB%91%E8% AF% 9D% E2% 80% 9Dpolyfill

Foreword

In the Web front-end development of this rapidly changing era, always need to read some of the latest technology blog in English to keep up with the trend of the technology. And sometimes encounter some of the more high-frequency " argot " in the community which may already be well known in the " common language " , and less contact you but why not read. Like almost all Chinese people now know duang what it was, but a foreigner to learn Chinese just might see after a loss.



Black then also to learn, we collect a variety of Web development jargon. Here we introduce two.

Polyfill

Polyfill or Polyfiller, a British Web developer  Remy Sharp  in the coffee shop when racking our brains pit made out of. At that time he wanted to use one word to describe "with JavaScript (or something like ghost Flash) to achieve some browsers do not support native API". Shim the first time this has some words in his mind. But he thought for a moment back Shim generally have their own API, rather than simply not supported by the realization native API. Can not think of the right word has been tried to think, so he made a huff word Polyfill. In addition to his own use of the word outside, he returned with other developers. With his frequent mention of the word in a variety of Web conference presentations and his book "Introducing HTML5" in, we spent all feel very good to work together with.

Polyfill exact meaning: code for implementing the native API browser does not support.

For example, querySelectorAll many modern browsers support native Web API, but some old browsers do not support, it is assumed that someone wrote a library, just use this library, you can use the document in the old browser inside. querySelectorAll, to use a modern browser with native API is no different. Well, this library can be called Polyfill or Polyfiller.
Well, then the question came. jQuery is not a Polyfill? The answer is No. Because it is not to achieve some standard native API, but encapsulates its own API. Polyfill is a smooth old and new browser  standard API native  of packaging a gap between, but not to achieve their API.
Some existing Polyfill, such as  Polymer  is to make older browsers can also be used on a Polyfill HTML5 Web Component of.FlashCanvas is implemented in Flash does not support the Canvas API lets browsers can also be used on the Polyfill Canvas.
 

Shim和Polyfill

In the JavaScript world, there are two words often mentioned, shim and polyfill. What they mean is, what is the difference?

A shim is a library, it will be introducing a new API to a legacy environment and relying on the existing legacy environment means to achieve .

A polyfill is a use in the browser the API shim. Our usual practice is to check the current browser supports an API, if you do not support it loads the corresponding polyfill. Then the old and new browser can use this API the the term comes from a home improvement product polyfill Polyfilla:
Polyfilla is a British product called spackling Paste (Translator's Note: scraping the walls, known in China as putty) in the United States.

With this in mind on the line: the older browsers imagine become over the wall with cracks. these [polyfills] will help us crack this wall is smooth, but also one of our better smooth walls (browser)

Paul Irish posted a Polyfills summary page "HTML5 Cross browser Polyfills ".es5-shim is a shim (instead of polyfill) example, it implements the new features in ECMAScript ECMAScript 5 engine 3, and in Node.js and have exactly the same performance in the browser ( Translator's Note: because it in Node.js use on, not only on the browser, so it's not polyfill).

 

More professional front-end knowledge, make the [2048] ape www.mk2048.com

Guess you like

Origin blog.csdn.net/qq_29069777/article/details/102763927