| name | lighthouse |
| description | Google Lighthouse CLI reference for auditing web performance, accessibility, SEO, and best practices. Use this skill when users need to analyze website performance, run audits, generate reports, or integrate Lighthouse into their workflow. |
Google Lighthouse
Comprehensive reference for Google Lighthouse - an open-source, automated tool for improving the quality of web pages. It has audits for performance, accessibility, progressive web apps, SEO and more.
Source: https://github.com/GoogleChrome/lighthouse
NPM Package: https://www.npmjs.com/package/lighthouse
Documentation: https://developer.chrome.com/docs/lighthouse/overview/
Prerequisites
Requirements
- Node.js: Version 22 (LTS) or later
- Chrome/Chromium: Version 66.0 or later
Installation
npm install -g lighthouse
yarn global add lighthouse
lighthouse --version
Chrome Setup
Lighthouse uses Chrome/Chromium. You can:
- Use existing Chrome/Chrome Canary installation
- Set custom Chrome binary via
CHROME_PATH environment variable
- Pass custom flags via
--chrome-flags
Quick Start
lighthouse https://example.com
lighthouse https://example.com --view
lighthouse https://example.com --output json
lighthouse https://example.com --output-path ./report.html
CLI Options
Output Options
lighthouse <url> --output <format> --output-path <path>
--output html
--output json
--output csv
lighthouse https://example.com --output json
lighthouse https://example.com --output html --output-path ./audit.html
lighthouse https://example.com --output json --output html
Audit Categories
lighthouse https://example.com --only-categories=performance,accessibility
lighthouse https://example.com --skip-audits=unused-javascript,offscreen-images
lighthouse --list-all-audits
Presets & Device Emulation
lighthouse https://example.com --preset=desktop
lighthouse https://example.com --preset=perf
lighthouse https://example.com --preset=experimental
lighthouse https://example.com --form-factor=mobile
lighthouse https://example.com --form-factor=desktop
lighthouse https://example.com --screenEmulation.mobile
lighthouse https://example.com --screenEmulation.width=1280 --screenEmulation.height=720
lighthouse https://example.com --screenEmulation.disabled
Network & CPU Throttling
--throttling-method=simulate
--throttling-method=devtools
--throttling-method=provided
--throttling.rttMs=150
--throttling.throughputKbps=1600
--throttling.cpuSlowdownMultiplier=4
Chrome Configuration
CHROME_PATH=/path/to/chrome lighthouse https://example.com
lighthouse https://example.com --chrome-flags="--headless --no-sandbox"
lighthouse https://example.com --chrome-flags="--window-size=412,660"
lighthouse https://example.com --chrome-flags="--disable-gpu --disable-dev-shm-usage"
--port=9222
--hostname=localhost
Advanced Options
--max-wait-for-load=60000
--save-assets
--disable-full-page-screenshot
--disable-storage-reset
--blocked-url-patterns="*.png" --blocked-url-patterns="*.jpg"
--extra-headers="{\"Cookie\":\"monster=blue\", \"Authorization\":\"Bearer token\"}"
--locale=en
--plugins=lighthouse-plugin-field-performance
Lifecycle Modes
Gather Mode (Collect Artifacts)
lighthouse https://example.com --gather-mode
lighthouse https://example.com -G=./artifacts/
Audit Mode (Process Saved Artifacts)
lighthouse --audit-mode
lighthouse -A=./artifacts/
Combined Mode
lighthouse https://example.com -GA
lighthouse https://example.com -GA=./my-run/
Configuration File
Create lighthouse-config.js:
module.exports = {
extends: 'lighthouse:default',
settings: {
formFactor: 'desktop',
throttling: {
rttMs: 40,
throughputKbps: 10240,
cpuSlowdownMultiplier: 1,
},
screenEmulation: {
mobile: false,
width: 1350,
height: 940,
deviceScaleFactor: 1,
disabled: false,
},
emulatedUserAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)',
onlyCategories: ['performance', 'accessibility', 'best-practices', 'seo'],
},
};
Use it:
lighthouse https://example.com --config-path=./lighthouse-config.js
Viewing Reports
HTML Reports
lighthouse https://example.com --view
open ./example.com_2024-01-01.report.html
JSON Reports
lighthouse https://example.com --output=json --output-path=./report.json
cat ./report.json | xclip -selection clipboard
Online Viewer
Upload JSON reports to: https://googlechrome.github.io/lighthouse/viewer/
- Drag and drop JSON files
- Share reports as secret GitHub gists
- Compare historical reports
Common Use Cases
Mobile Performance Audit
lighthouse https://example.com \
--form-factor=mobile \
--only-categories=performance \
--preset=perf \
--view
Desktop Full Audit
lighthouse https://example.com \
--preset=desktop \
--view
CI/CD Integration
lighthouse https://example.com --quiet --chrome-flags="--headless --no-sandbox"
lighthouse https://example.com --output=json --quiet > report.json
Batch Auditing
for url in https://example.com https://example.com/about; do
lighthouse "$url" --output=json --output-path="./reports/$(echo $url | sed 's/[^a-zA-Z0-9]/_/g').json"
done
Authenticated Pages
lighthouse https://example.com/dashboard \
--extra-headers="{\"Cookie\":\"sessionid=abc123; auth_token=xyz\"}"
Performance Budgets
Lighthouse doesn't enforce budgets natively, but you can combine with lighthouse-ci:
npm install -g @lhci/cli
lhci autorun --config=lighthouserc.js
Example lighthouserc.js:
module.exports = {
ci: {
assert: {
assertions: {
'categories:performance': ['warn', {minScore: 0.9}],
'categories:accessibility': ['error', {minScore: 1}],
'first-contentful-paint': ['warn', {maxNumericValue: 2000}],
},
},
},
};
Troubleshooting
Chrome Won't Start
lighthouse https://example.com --chrome-flags="--headless --no-sandbox --disable-gpu"
chrome --version
CHROME_PATH=/usr/bin/google-chrome-stable lighthouse https://example.com
Connection Issues
lighthouse https://example.com --port=9222
lighthouse https://example.com --max-wait-for-load=90000
Large Trace Files
lighthouse https://example.com --disable-full-page-screenshot
Key Metrics Reference
| Metric | Target | Description |
|---|
| Performance Score | 90+ | Overall performance score (0-100) |
| First Contentful Paint (FCP) | < 1.8s | First text/image painted |
| Largest Contentful Paint (LCP) | < 2.5s | Largest element painted |
| Total Blocking Time (TBT) | < 200ms | Main thread blocked time |
| Cumulative Layout Shift (CLS) | < 0.1 | Visual stability score |
| Speed Index | < 3.4s | Visual completeness speed |
Related Tools
- Lighthouse CI: Continuous integration for Lighthouse
- Lighthouse Viewer: Online report viewer
- Lighthouse CLI: This tool (Node module also available)
- Chrome DevTools: Built-in Lighthouse panel
Resources