Bundle polyfills based on a User-Agent header
Latest commit 8ce4229 Jun 19, 2017
Failed to load latest commit information.
lib Polyfill 404 craches app Nov 24, 2015
test fixed test Nov 24, 2015
.travis.yml remove 0.8 Sep 22, 2014
LICENSE user-agent-based polyfill combinator Jun 3, 2014
README.md Update README.md Mar 16, 2015
package.json 2.1.1 Dec 21, 2014



NPM version Build status Test coverage Dependency Status License Downloads Gittip

Create polyfill builds based on the client's browser and serve only what's needed. This allows you to write modern JavaScript without worrying too much (you should still do due diligence) about browser support as well as not penalizing modern browsers with unnecessary polyfills. See https://polyfills.github.io for more details.


This library is merely the "logic" and does not handle any HTTP serving. It essentially does the following:

  • Parses user agent strings for <family> <major>.<minor>.<version> and creates polyfill bundles based on these variables.
  • Returned a bundle of all the minified polyfills.


npm install polyfills


var polyfills = require('polyfills')
var polyfill = polyfills(options)
var js = polyfill(<useragent>)

polyfills.load.then( => )

The first .update() instance. Wait until the polyfills are loaded before using this library.

polyfills.update().then( => )

Reload all the polyfills from the source.

var polyfill = polyfills([options])

The options are:

  • include - which polyfills to include. This is an inclusive list. The names are included in polyfills/db.
  • exclude - conversely, you can exclude specific polyfills.

var js = polyfill(useragent)

Bundle a polyfill for a useragent.

app.use(function (req, res, next) {
  var js = polyfill(req.headers['user-agent')

Adding polyfills

Checkout polyfills/db.