Open In App

What is the difference between a shim and a polyfill ?

Improve
Improve
Like Article
Like
Save
Share
Report

Shim: Shim library in the JavaScript language is the concept that actually blocks API (Application programming interface) calls and also modifies the parameters passed, also handles the operation itself or sometimes redirects the operation to some other place. Shim can be also used for executing programs on various software platforms that they were developed for. Shim cannot add the missing implementation in an API call.

Polyfill: Polyfill or Polyfilling is the next version or superior version of Shim or Shimming. Polyfill is the concept of implementing the lost features in an API call, where the Shim cannot implement the lost features. Polyfill is a piece of code or a plugin that offers the technology that you as a developer expect the web browser to provithatde natively. Polyfill adds legacy browsers with modern HTML5/CSS3 implementation.

Difference between Shim and Polyfill:

Shim

Polyfill

Shim is a simple library that brings a newer API to an older platform environment. Ployfill is the Shim for a web browser API which checks if the browser has the support to an API
Shim code could add (i.e. JavaScript) that would fix some functionality, but it would most often have its own API. Polyfill is something you could drop in (i.e. JavaScript) and it would silently work to imitate existing browser APIs that are otherwise unsupported.
Shim doesn’t install the missing features in an API call. Polyfill installs its own implementation if the features are missing.
Shim can only correct the behavior of code that already exists, Polyfill implements a feature on web browsers that do not support the feature whether it is existing or not.

Last Updated : 10 Feb, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads