polyfills

2019-09-12

polyfills是什么

什么是polyfills,user-agent-based polyfill combinator

polyfills使用教程帮助文档

Polyfills

NPM versionBuild statusTest coverageDependency StatusLicenseDownloadsGittip

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.iofor more details.

Description

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.

Installation

npm install polyfills

Usage

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 inclusivelist. 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')
  res.type('js')
  res.send(js)
})

Adding polyfills

Checkout polyfills/db.


上一篇:aster-uglify
下一篇:livescript-middleware
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部