Skip to content
Switch branches/tags


Failed to load latest commit information.
Latest commit message
Commit time
Sep 29, 2016
Sep 29, 2016
Sep 29, 2016


Like polyfill but with pony pureness

Use for linking here.

Pony pureness, really?

While polyfills are naughty, ponyfills are pure, just like ponies.

How are ponyfills better than polyfills?

A polyfill is code that adds missing functionality by monkey patching an API. Unfortunately, it usually globally patches built-ins, which affects all code running in the environment. This is especially problematic when a polyfill is not fully spec compliant (which in some cases is impossible), as it could cause very hard to debug bugs and inconsistencies. Or when the spec for a new feature changes and your code depends on behavior that a module somewhere else in the dependency tree polyfills differently. In general, you should not modify API's you don't own.

A ponyfill, in contrast, doesn't monkey patch anything, but instead exports the functionality as a normal module, so you can use it locally without affecting other code.

tl;dr; Polyfills are naughty as they patch native APIs, while ponyfills are pure and don't affect the environment.


Number.isNaN = Number.isNaN || function (value) {
	return value !== value;



module.exports = function (value) {
	return value !== value;
var isNanPonyfill = require('is-nan-ponyfill');


Ponyfills should avoid using native APIs, because potential bugs or differences in the native APIs will make such a ponyfill less robust (therefore defeating one of its main purposes). There are important exceptions, such as when:

  • There is no way to implement some of the ponyfill without native APIs.
  • Reimplementing native parts would have a large cost (e.g. performance or code size).

In such cases, it's still valuable for the ponyfill to minimize any assumptions about the underlying environment.

Where can I find ponyfills?

Search npm.

How do I make a ponyfill?

  • Read the specification or source code of the feature you want to ponyfill.
  • Initialize an npm package.
  • Write some tests to ease writing the ponyfill logic.
  • Link to documentation about the feature in your readme. Example.
  • Link to in your readme. Example.
  • Add ponyfill to the keywords section in package.json.
  • Publish!




To the extent possible under law, Sindre Sorhus has waived all copyright and related or neighboring rights to this work.

Header based on work by Mary Winkler.


πŸ¦„ Like polyfill but with pony pureness



Code of conduct


No releases published


No packages published