Search code examples
terminologynamingvocabularypolyfillsshim

What is the difference between a shim and a polyfill?


Both seem to be used in web development circles, see e.g. HTML5 Cross Browser Polyfills, which says:

So here we're collecting all the shims, fallbacks, and polyfills...

Or, there's the es5-shim project.

In my current project we're using a number of these, and I want to stick them all in the same directory. So, what should I call this directory---shims, or polyfills?


Solution

    • A shim is any piece of code that performs interception of an API call and provides a layer of abstraction. It isn't necessarily restricted to a web application or HTML5/CSS3.

    • A polyfill is a type of shim that retrofits legacy browsers with modern HTML5/CSS3 features usually using Javascript or Flash.

    Answering your specific question, call your directory shims if you want to keep the directory generic.