@fastly/performance-observer-polyfill

中文文档
2.0.0发布于 2021/02/23MITTypeScriptESM + CJS近 30 天下载 25.6万

* 业绩观察员

中文使用文档
文档目录11 节
  1. 快速链接
  2. 安装
  3. 用法 :
  4. 作为一名 多边填充
  5. 用法:作为 填马
  6. 洞穴
  7. 发展
  8. 所需资源
  9. 安装
  10. 运行
  11. 许可证

* 业绩观察员

Travis gzip size

这个 PerformanceObserver 界面是一个 JavaScript API,可用于观测 时间线 在记录时,应通知新的业绩计量.

这种多填充允许消费者使用 PerformanceObserver 界面在浏览器环境中,它们具有基本的性能时间线支持(I.e. window.performance.getEntries())),但没有观察者支持.

综合填充工作是回到投票时段的投票,并给所有订阅的观察员打电话,请他们提供整套投票结果.

安装

npm install --save @fastly/performance-observer-polyfill

用法 :

作为一名 多边填充

自动“ 安装” 性能观察器 window.PerformanceObserver() 如果检测到性能观察器不支持:

import '@fastly/performance-observer-polyfill/polyfill'

// PerformanceObserver is now available globally!
const observer = new PerformanceObserver((list) => {});
observer.observe({entryTypes: ['resource']});

用法:作为 填马

用一个模块捆绑器像 滚动 或者说 网络软件包, (中文(简体) ), 您可以导入 @fastly/performance-observer-polyfill 在代码中不修改任何全局 :

// using JS Modules:
import PerformanceObserver from '@fastly/performance-observer-polyfill'

// or using CommonJS:
const PerformanceObserver = require('@fastly/performance-observer-polyfill')

// usage:
const observer = new PerformanceObserver((list) => {});
observer.observe({entryTypes: ['resource']})

洞穴

由于多填充方式通过回归投票执行绩效观察员界面,通过呼叫恢复投票 window.performance.getEntries() 我们仅限于披露时间轴条目类型,这些类型由 getEntries()因此,多填充只能用于观察条目类型: navigation, (中文(简体) ), resource 财务报告和审定财务报表 mark。更新条目类型,例如 paint 只能通过当地执行绩效观察员进行曝光,因此不能进行多填.

发展

所需资源

  • 节点.js 10

安装

git clone [email protected]:fastly/performance-observer-polyfill.git
cd performance-observer-polyfill
npm install
npm run build

运行

在开发绩效-观测-渗透功能的同时,您希望执行的大多数行动被定义为国家预防机制脚本,可以使用 npm run {task}。 。 。 .

所有命令及其描述的列表如下.

名称说明
构建编译生产环境应用程序
构建: dev编译开发应用程序
线性使用 ESLint 将源文件用于样式错误, 并使用更漂亮的格式自动格式化源文件
测试运行单元测试套件

许可证

麻省理工学院

版本与发布记录

@fastly/performance-observer-polyfill 共发布 12 个版本,首次发布于 2019/06/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.0latest2021/02/235 年前
2.0.0-pre-1.3next2021/02/165 年前
2.0.0-pre-1.22021/02/165 年前
2.0.0-pre-1.12021/02/165 年前
2.0.0-pre-1.02021/02/115 年前
2.0.0-pre-12021/02/105 年前

关于 @fastly/performance-observer-polyfill 的常见问题

@fastly/performance-observer-polyfill 是什么?

* 业绩观察员

如何安装 @fastly/performance-observer-polyfill?

在项目目录运行 npm install @fastly/performance-observer-polyfill,或使用 pnpm add / yarn add / bun add。

@fastly/performance-observer-polyfill 支持 TypeScript 吗?

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

@fastly/performance-observer-polyfill 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fastly/performance-observer-polyfill 可以商用吗?

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

@fastly/performance-observer-polyfill 的下载量有多少?

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

@fastly/performance-observer-polyfill 还在维护吗?

最新版本 2.0.0 发布于 2021/02/23(5 年前);至今共发布 12 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/06/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。