@luhanxin/performance
v3.0.0
Published
Web performance metrics and budget checks for Puppeteer pages
Downloads
442
Maintainers
Readme
@luhanxin/performance
采集 Puppeteer 页面 Web 性能指标并执行性能预算。
安装
pnpm add @luhanxin/performance使用
import {measurePerformance} from '@luhanxin/performance';
const result = await measurePerformance(page, {
fcp: 1800,
lcp: 2500,
cls: 0.1,
ttfb: 800,
totalResourceBytes: 1_000_000
});
if (result.violations.length > 0) {
throw new Error(result.violations.join('; '));
}采集 FCP、LCP、CLS、TTFB、DOM 加载、Load、资源数量和传输体积。
API
collectPerformance(page)checkPerformanceBudget(metrics, budget)measurePerformance(page, budget?)
构建
pnpm build
pnpm typecheck