user-agent-based polyfill combinator


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>)

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

Reload all the polyfills from the source.

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.

Bundle a polyfill for a useragent.

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

Checkout polyfills/db.