@browserless/lighthouse 10.9.15 → 10.9.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +140 -8
  2. package/package.json +20 -12
package/README.md CHANGED
@@ -1,14 +1,18 @@
1
1
  <div align="center">
2
- <br>
3
2
  <img style="width: 500px; margin:3rem 0 1.5rem;" src="https://github.com/microlinkhq/browserless/raw/master/static/logo-banner.png#gh-light-mode-only" alt="browserless">
4
3
  <img style="width: 500px; margin:3rem 0 1.5rem;" src="https://github.com/microlinkhq/browserless/raw/master/static/logo-banner-light.png#gh-dark-mode-only" alt="browserless">
5
- <br>
6
- <br>
7
- <p align="center"><strong>@browserless/lighthouse</strong>: Browserless Lighthouse integration using puppeteer.</p>
8
- <p align="center">See <a href="https://browserless.js.org/#%2F%3Fid=lighthouse" target='_blank' rel='noopener noreferrer'>lighthouse</a> section our <a href="https://browserless.js.org" target='_blank' rel='noopener noreferrer'>website</a> for more information.</p>
9
- <br>
4
+ <br><br>
5
+ <a href="https://microlink.io"><img src="https://img.shields.io/badge/powered_by-microlink.io-blue?style=flat-square&color=%23EA407B" alt="Powered by microlink.io"></a>
6
+ <img src="https://img.shields.io/github/tag/microlinkhq/browserless.svg?style=flat-square" alt="Last version">
7
+ <a href="https://coveralls.io/github/microlinkhq/browserless"><img src="https://img.shields.io/coveralls/microlinkhq/browserless.svg?style=flat-square" alt="Coverage Status"></a>
8
+ <a href="https://www.npmjs.org/package/browserless"><img src="https://img.shields.io/npm/dm/browserless.svg?style=flat-square" alt="NPM Status"></a>
9
+ <br><br>
10
10
  </div>
11
11
 
12
+ > @browserless/lighthouse: Browserless Lighthouse integration using puppeteer.
13
+
14
+ See the [lighthouse section](https://browserless.js.org/#/?id=lighthouse) on our website for more information.
15
+
12
16
  ## Install
13
17
 
14
18
  Using npm:
@@ -17,9 +21,137 @@ Using npm:
17
21
  npm install @browserless/lighthouse --save
18
22
  ```
19
23
 
20
- ## Usage
24
+ ## About
25
+
26
+ 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.
27
+
28
+ ### What this package does
29
+
30
+ The `@browserless/lighthouse` package allows you to:
31
+
32
+ - **Run Lighthouse audits** with full performance, accessibility, SEO, and PWA analysis
33
+ - **Generate reports** in JSON, HTML, or CSV formats
34
+ - **Use Lighthouse presets** for desktop or mobile configurations
35
+ - **Customize audits** by selecting specific categories or skipping certain checks
36
+ - **Integrate seamlessly** with your existing browserless browser instance
37
+
38
+ ### Usage
39
+
40
+ ```js
41
+ const createLighthouse = require('@browserless/lighthouse')
42
+ const createBrowser = require('browserless')
43
+
44
+ // Create a browserless instance
45
+ const browser = createBrowser()
46
+
47
+ // Create the lighthouse function with teardown support
48
+ const lighthouse = createLighthouse(async teardown => {
49
+ const browserless = await browser.createContext()
50
+ teardown(() => browserless.destroyContext())
51
+ return browserless
52
+ })
53
+
54
+ // Run an audit
55
+ const report = await lighthouse('https://example.com')
56
+ console.log(report.categories.performance.score)
57
+ ```
58
+
59
+ ### Options
60
+
61
+ | Option | Type | Default | Description |
62
+ |--------|------|---------|-------------|
63
+ | `output` | `string` | `'json'` | Report format: `'json'`, `'html'`, or `'csv'` |
64
+ | `timeout` | `number` | — | Audit timeout in milliseconds |
65
+ | `preset` | `string` | — | Lighthouse preset: `'lr-desktop'`, `'lr-mobile'`, etc. |
66
+ | `flags` | `object` | — | [Lighthouse flags](https://github.com/GoogleChrome/lighthouse/blob/main/docs/configuration.md) |
67
+ | `onlyAudits` | `string[]` | — | Run only specific audits |
68
+ | `skipAudits` | `string[]` | — | Skip specific audits |
69
+ | `onlyCategories` | `string[]` | — | Run only specific categories |
70
+
71
+ ### Output formats
72
+
73
+ ```js
74
+ // JSON (default) - returns the Lighthouse Result object (lhr)
75
+ const jsonReport = await lighthouse(url, { output: 'json' })
76
+ console.log(jsonReport.categories.performance) // 0.95
77
+
78
+ // HTML - returns the full HTML report as a string
79
+ const htmlReport = await lighthouse(url, { output: 'html' })
80
+ await fs.writeFile('report.html', htmlReport)
81
+
82
+ // CSV - returns CSV-formatted data
83
+ const csvReport = await lighthouse(url, { output: 'csv' })
84
+ ```
85
+
86
+ ### Lighthouse presets
87
+
88
+ Use built-in Lighthouse presets for common configurations:
89
+
90
+ ```js
91
+ // Desktop configuration (higher viewport, no throttling)
92
+ const report = await lighthouse(url, { preset: 'lr-desktop' })
93
+
94
+ // Mobile configuration (smaller viewport, CPU/network throttling)
95
+ const report = await lighthouse(url, { preset: 'lr-mobile' })
96
+ ```
97
+
98
+ ### Customizing audits
99
+
100
+ ```js
101
+ // Run only accessibility audits
102
+ const report = await lighthouse(url, {
103
+ onlyAudits: ['accessibility']
104
+ })
105
+
106
+ // Run only specific categories
107
+ const report = await lighthouse(url, {
108
+ onlyCategories: ['performance', 'accessibility']
109
+ })
110
+
111
+ // Skip specific audits
112
+ const report = await lighthouse(url, {
113
+ skipAudits: ['uses-http2', 'bf-cache']
114
+ })
115
+ ```
116
+
117
+ ### Report structure (JSON)
118
+
119
+ When using JSON output, the report includes:
120
+
121
+ ```js
122
+ const report = await lighthouse(url)
123
+
124
+ // Categories with scores (0-1)
125
+ report.categories.performance.score // Performance score
126
+ report.categories.accessibility.score // Accessibility score
127
+ report.categories.seo.score // SEO score
128
+ report.categories['best-practices'].score // Best practices score
129
+ report.categories.pwa.score // PWA score (if applicable)
130
+
131
+ // Individual audits
132
+ report.audits['first-contentful-paint'].numericValue // FCP in ms
133
+ report.audits['largest-contentful-paint'].numericValue // LCP in ms
134
+ report.audits['cumulative-layout-shift'].numericValue // CLS score
135
+ report.audits['total-blocking-time'].numericValue // TBT in ms
136
+
137
+ // Configuration used
138
+ report.configSettings
139
+ ```
140
+
141
+ ### How it fits in the monorepo
142
+
143
+ This is an **extended functionality package** for performance auditing:
144
+
145
+ | Consumer | Purpose |
146
+ |----------|---------|
147
+ | `@browserless/cli` | Powers the `browserless lighthouse` command |
148
+ | User applications | Performance monitoring, CI/CD quality gates |
149
+
150
+ ### Dependencies
21
151
 
22
- See [browseress#lighthouse](https://browserless.js.org/#/?id=running-lighthouse).
152
+ | Package | Purpose |
153
+ |---------|---------|
154
+ | `lighthouse` | Google Lighthouse core library |
23
155
 
24
156
  ## License
25
157
 
package/package.json CHANGED
@@ -1,33 +1,41 @@
1
1
  {
2
2
  "name": "@browserless/lighthouse",
3
- "description": "Browserless Lighthouse integration using puppeteer.",
3
+ "description": "Run Google Lighthouse audits on websites using headless Chrome. Get performance, accessibility, and SEO metrics.",
4
4
  "homepage": "https://browserless.js.org",
5
- "version": "10.9.15",
5
+ "version": "10.9.18",
6
6
  "main": "src",
7
+ "author": {
8
+ "email": "hello@microlink.io",
9
+ "name": "microlink.io",
10
+ "url": "https://microlink.io"
11
+ },
7
12
  "repository": {
13
+ "directory": "packages/lighthouse",
8
14
  "type": "git",
9
15
  "url": "git+https://github.com/microlinkhq/browserless.git#master"
10
16
  },
11
17
  "bugs": {
12
- "url": "https://github.com/microlinkhq/browserless"
18
+ "url": "https://github.com/microlinkhq/browserless/issues"
13
19
  },
14
20
  "keywords": [
15
21
  "browserless",
16
- "chromeless",
22
+ "lighthouse",
17
23
  "headless",
18
- "httpstat",
19
- "httpstats",
20
- "lighhouse",
21
- "metrics",
24
+ "chrome",
22
25
  "puppeteer",
26
+ "performance",
27
+ "audit",
28
+ "seo",
29
+ "accessibility",
30
+ "metrics",
23
31
  "pwa",
24
- "stats"
32
+ "web-vitals"
25
33
  ],
26
34
  "dependencies": {
27
- "lighthouse": "~12.8.2"
35
+ "lighthouse": "~13.0.1"
28
36
  },
29
37
  "devDependencies": {
30
- "@browserless/test": "^10.9.15",
38
+ "@browserless/test": "^10.9.18",
31
39
  "ava": "5"
32
40
  },
33
41
  "engines": {
@@ -45,5 +53,5 @@
45
53
  "timeout": "2m",
46
54
  "workerThreads": false
47
55
  },
48
- "gitHead": "b7e795fe720ee15519ecb14210fc4b11379e25ad"
56
+ "gitHead": "f5e8cd0788e4bad3b3ad9b007943754f96653817"
49
57
  }