@github/browser-support

中文文档
4.5.3发布于 2026/11/05MITTypeScriptES Module构建来源已验证近 30 天下载 1.4万

Polyfills and Capable Browser detection

原始使用文档
文档目录12 节
  1. How is this used on GitHub?
  2. Installation
  3. Usage
  4. JS
  5. Development
  6. Upgrading browser-support in Dotcom
  7. Review lab testing
  8. Production deployment
  9. Contributing
  10. Adding polyfills
  11. Removing polyfills
  12. License

browser-support

This library allows websites to maintain compatibility with older browsers, which do not implement newer features. It does so using polyfills for small new features, plus functions to determine if a browser supports a set of features natively or with polyfills.

If you would like to see what features the browser you are currently using implements, you can visit the documentation site which displays a compatibility table that detects which features are natively supported in your browser.

How is this used on GitHub?

We use all of these polyfills on GitHub.com. We also use the isSupported() function to determine if the browser meets a minimum set of functionality which we expect, browser that return false from isSupported() do not send errors or statistics to our backend monitoring.

Installation

$ npm install @github/browser-support

Usage

JS

import {isSupported, isPolyfilled, apply} from '@github/browser-support'

// Check if a browser is supported
if (!isSupported()) {
  apply()
  console.assert(isSupported() === true)
  console.assert(isPolyfilled() === true)
}

Development

npm install
npm test

Upgrading browser-support in Dotcom

During upgrades, it is crucial to ensure that browser error reporting to Sentry is not disrupted. Use the following steps to validate this functionality:

Review lab testing

  • Create a PR to upgrade the browser-support version in Dotcom.
  • Trigger a browser error from your review-lab instance and confirm it is reported in Sentry:
    • Append #b00m to your review-lab URL (e.g. https://branchname.review-lab.github.com#b00m) and refresh the page.
    • Confirm the error is reported in review-lab Sentry.
    • Perform these steps in Chrome, Firefox, Edge, and Opera. Note: Errors are currently not reported in Safari due to an open issue.

Production deployment

  • Check the browser-reporting monitor.
    • If the rate of reported browser errors drops, the monitor will trigger an alert in the #web-systems-ops channel.
  • After deploying to canary:
    • Trigger a browser error by appending #b00m to your URL.
    • Confirm the error is reported in canary Sentry.
  • After deploying to production:

Contributing

Adding polyfills

Please do not add any polyfills for ECMA features that are Stage 3 or below. We only wish to polyfill features from ECMAScript that are Stage 4 (about to be included in a new years specification) or already specified.

Removing polyfills

Polyfills should only be removed after consulting with the @github/web-systems who will determine if a polyfill can be removed. This code is designed to be kept lightweight, we do not want to ship dozens of kb of polyfills.

As a polyfill is removed, it may be worth adding feature detection to the baseSupport const, to ensure that our baseline moves with our browser support matrix.

License

Distributed under the MIT license. See LICENSE for details.

版本与发布记录

@github/browser-support 共发布 35 个版本,首次发布于 2022/02/08;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.5.3latest2026/11/0511 天前
4.5.22026/11/0511 天前
4.5.12026/04/047 个月前
4.5.02026/02/248 个月前
4.4.12026/02/218 个月前
4.4.02026/02/218 个月前

关于 @github/browser-support 的常见问题

@github/browser-support 是什么?

Polyfills and Capable Browser detection

如何安装 @github/browser-support?

在项目目录运行 npm install @github/browser-support,或使用 pnpm add / yarn add / bun add。

@github/browser-support 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@github/browser-support 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@github/browser-support 可以商用吗?

@github/browser-support 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@github/browser-support 的下载量有多少?

根据 npm 官方下载统计,@github/browser-support 在 2026/10/17 – 2026/11/15 这 30 天内被下载 13,925 次,日均约 464 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@github/browser-support 还在维护吗?

最新版本 4.5.3 发布于 2026/11/05(11 天前);至今共发布 35 个版本,其中过去 12 个月发布了 6 个;首次发布于 2022/02/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。