What is the difference between a shim and a polyfill?

Technology CommunityCategory: JavaScriptWhat is the difference between a shim and a polyfill?
VietMX Staff asked 4 years ago
  • 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.
  • polyfill is a type of shim that retrofits legacy browsers with modern HTML5/CSS3 features usually using Javascript or Flash.

A shim is a library that brings a new API to an older environment, using only the means of that environment. Thus, a polyfill is a shim for a browser API.