A piece of code that intercepts APIs to create an abstract layer between the caller and the target. Usually, shims are used for implementing backward compatibility or fix functionality using its own API.

Compared to polyfills, shims are more generic and not necessarily restricted to HTML, CSS, and JavaScript. Shims use their own API to do their job while polyfills can be simply loaded and would silently do their job and work.