What is the difference between shim and polyfill

Reprinted from Baidu:

In the JavaScript world, two words are often mentioned, shim and polyfill. What do they both refer to, and what's the difference? 
A shim is a library that brings a new API into an old environment , and only relying on the existing means in the old environment to implement
a polyfill is a shim used on the browser API. Our usual practice is to first check whether the current browser supports an API, and if not, load the corresponding polyfill . Then both old and new browsers can use this API. The term polyfill comes from a home improvement product Polyfilla:

Polyfilla is a British product, called Spackling Paste in the United States. Just remember this: think of the old browser as a wall with cracks. These [polyfills] will help us smooth out the cracks in this wall and give us a better smooth wall (the browser)
Paul Irish has published a summary page of Polyfills "HTML5 Cross Browser Polyfills". es5-shim is an example of a shim (not a polyfill) that implements the new features of ECMAScript 5 on the ECMAScript 3 engine, but also in Node.js It has exactly the same performance on the browser as it does on the browser (Translator's Note: Because it works on Node .
In the JavaScript world, two words are often mentioned, shim and polyfill. What do they both refer to, and what's the difference? 
A shim is a library that brings a new API into an old environment , and only relying on the existing means in the old environment to implement
a polyfill is a shim used on the browser API. Our usual practice is to first check whether the current browser supports an API, and if not, load the corresponding polyfill . Then both old and new browsers can use this API. The term polyfill comes from a home improvement product Polyfilla:

Polyfilla is a British product, called Spackling Paste in the United States. Just remember this: think of the old browser as a wall with cracks. These [polyfills] will help us smooth out the cracks in this wall and give us a better smooth wall (the browser)
Paul Irish has published a summary page of Polyfills "HTML5 Cross Browser Polyfills". es5-shim is an example of a shim (not a polyfill) that implements the new features of ECMAScript 5 on the ECMAScript 3 engine, but also in Node.js It has exactly the same performance on the browser as it does on the browser (Translator's Note: Because it works on Node .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325233993&siteId=291194637