@browserless/lighthouse

中文文档
14.1.2发布于 2026/11/03MITCommonJS近 30 天下载 2824

Run Google Lighthouse audits on websites using headless Chrome. Get performance, accessibility, and SEO metrics.

原始使用文档
文档目录12 节
  1. Install
  2. About
  3. What this package does
  4. Usage
  5. Options
  6. Output formats
  7. Lighthouse presets
  8. Customizing audits
  9. Report structure (JSON)
  10. How it fits in the monorepo
  11. Dependencies
  12. License
browserless browserless

Powered by microlink.io Last version Coverage Status NPM Status

@browserless/lighthouse: Browserless Lighthouse integration using puppeteer.

See the lighthouse section on our website for more information.

Install

Using npm:

npm install @browserless/lighthouse --save

About

This package provides Google Lighthouse integration for browserless, allowing you to run performance, accessibility, SEO, and best practices audits on any URL using your existing browserless setup.

What this package does

The @browserless/lighthouse package allows you to:

  • Run Lighthouse audits with full performance, accessibility, SEO, and PWA analysis
  • Generate reports in JSON, HTML, or CSV formats
  • Use Lighthouse presets for desktop or mobile configurations
  • Customize audits by selecting specific categories or skipping certain checks
  • Reuse your existing browserless instance for the audit

Usage

const createLighthouse = require('@browserless/lighthouse')
const createBrowser = require('browserless')

// Create a browserless instance
const browser = createBrowser()

// Create the lighthouse function with teardown support
const lighthouse = createLighthouse(async teardown => {
  const browserless = await browser.createContext()
  teardown(() => browserless.destroyContext())
  return browserless
})

// Run an audit
const report = await lighthouse('https://example.com')
console.log(report.categories.performance.score)

Options

OptionTypeDefaultDescription
outputstring'json'Report format: 'json', 'html', or 'csv'
timeoutnumber—Audit timeout in milliseconds
presetstring—Lighthouse preset: 'lr-desktop', 'lr-mobile', etc.
flagsobject—Lighthouse flags
onlyAuditsstring[]—Run only specific audits
skipAuditsstring[]—Skip specific audits
onlyCategoriesstring[]—Run only specific categories

Output formats

// JSON (default) - returns the Lighthouse Result object (lhr)
const jsonReport = await lighthouse(url, { output: 'json' })
console.log(jsonReport.categories.performance) // 0.95

// HTML - returns the full HTML report as a string
const htmlReport = await lighthouse(url, { output: 'html' })
await fs.writeFile('report.html', htmlReport)

// CSV - returns CSV-formatted data
const csvReport = await lighthouse(url, { output: 'csv' })

Lighthouse presets

Use built-in Lighthouse presets for common configurations:

// Desktop configuration (higher viewport, no throttling)
const report = await lighthouse(url, { preset: 'lr-desktop' })

// Mobile configuration (smaller viewport, CPU/network throttling)
const report = await lighthouse(url, { preset: 'lr-mobile' })

Customizing audits

// Run only specific audits
const report = await lighthouse(url, {
  onlyAudits: ['first-contentful-paint', 'largest-contentful-paint']
})

// Run only specific categories
const report = await lighthouse(url, {
  onlyCategories: ['performance', 'accessibility']
})

// Skip specific audits
const report = await lighthouse(url, {
  skipAudits: ['uses-http2', 'bf-cache']
})

Report structure (JSON)

When using JSON output, the report includes:

const report = await lighthouse(url)

// Categories with scores (0-1)
report.categories.performance.score      // Performance score
report.categories.accessibility.score    // Accessibility score
report.categories.seo.score              // SEO score
report.categories['best-practices'].score // Best practices score
report.categories.pwa.score              // PWA score (if applicable)

// Individual audits
report.audits['first-contentful-paint'].numericValue  // FCP in ms
report.audits['largest-contentful-paint'].numericValue // LCP in ms
report.audits['cumulative-layout-shift'].numericValue  // CLS score
report.audits['total-blocking-time'].numericValue      // TBT in ms

// Configuration used
report.configSettings

How it fits in the monorepo

This is an extended functionality package for performance auditing:

ConsumerPurpose
@browserless/cliPowers the browserless lighthouse command

Dependencies

PackagePurpose
lighthouseGoogle Lighthouse core library

License

@browserless/lighthouse © Microlink, released under the MIT License.
Authored and maintained by Microlink with help from contributors.

The logo has been designed by xinh studio.

microlink.io · GitHub microlinkhq · X @microlinkhq

版本与发布记录

@browserless/lighthouse 共发布 200 个版本,首次发布于 2020/03/03;过去 12 个月发布了 38 个版本。

版本发布日期距今
14.1.2latest2026/11/035 天前
14.0.222026/10/1326 天前
14.0.02026/10/081 个月前
13.12.52026/09/261 个月前
13.9.232026/09/141 个月前
13.9.112026/09/062 个月前

关于 @browserless/lighthouse 的常见问题

@browserless/lighthouse 是什么?

Run Google Lighthouse audits on websites using headless Chrome. Get performance, accessibility, and SEO metrics.

如何安装 @browserless/lighthouse?

在项目目录运行 npm install @browserless/lighthouse,或使用 pnpm add / yarn add / bun add。

@browserless/lighthouse 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/browserless__lighthouse 是否存在。

@browserless/lighthouse 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@browserless/lighthouse 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@browserless/lighthouse 可以商用吗?

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

@browserless/lighthouse 的下载量有多少?

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

@browserless/lighthouse 还在维护吗?

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