DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > What is the difference between a shim and a polyfill?

What is the difference between a shim and a polyfill?

Axel Rauschmayer user avatar by
Axel Rauschmayer
·
Dec. 20, 11 · Web Dev Zone · Interview
Like (0)
Save
Tweet
6.65K Views

Join the DZone community and get the full member experience.

Join For Free
In the JavaScript world, one frequently hears the words shim and polyfill. What are those things and what is the difference between them?

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

Polyfill. In October 2010, Remy Sharp blogged about the term “polyfill” [via Rick Waldron]:

A polyfill is a piece of code (or plugin) that provides the technology that you, the developer, expect the browser to provide natively. Flattening the API landscape if you will.

Thus, a polyfill is a browser-related shim. You typically check if a browser supports a given API and load a polyfill if it doesn’t. That allows you to use the API in either case. The term polyfill comes from a home improvement product:

Polyfilla is a UK product known as Spackling Paste in the US. With that in mind: think of the browsers as a wall with cracks in it. These [polyfills] help smooth out the cracks and give us a nice smooth wall of browsers to work with.


Polyfilla – image from tooled-up.com [via Paul]


Examples.
Paul Irish has published a list with “HTML5 Cross Browser Polyfills”. es5-shim is an example of a (non-polyfill) shim – it retrofits ECMAScript 5 features on ECMAScript 3 engines. It is purely language-related and makes just as much sense on Node.js as it does on browsers.

 

Source: http://www.2ality.com/2011/12/shim-vs-polyfill.html

Shim (computing)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Kubernetes Service Types Explained In-Detail
  • How BDD Works Well With EDA
  • Getting Started Building on the NEAR Network with Infura
  • Getting Started With RSocket Kotlin

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo