Lighthouse CI: Automate Performance Testing in CI/CD
Lighthouse CI (LHCI) is Google's official tool for running Lighthouse audits in continuous integration pipelines. It catches performance regressions before they reach production.
What is Lighthouse CI?
Lighthouse CI is a suite of tools that integrate Lighthouse into your CI/CD workflow:
- @lhci/cli — Command-line tool for running audits (~2M monthly npm downloads)
- @lhci/server — Optional server for storing historical data
- GitHub App — Status checks on pull requests
Why Use Lighthouse CI?
83% of Fortune 500 companies have integrated automated performance testing into their CI/CD pipelines. Without it, regressions slip through:
- Developer fixes performance issues
- PR gets merged
- Next week, someone adds a 500KB image
- Performance tanks, nobody notices until users complain
LHCI solves this by running Lighthouse on every commit and failing builds that don't meet your standards.
Key Features
- Regression prevention — Fail builds when Core Web Vitals like LCP, CLS, and TBT (proxy for INP) drop
- Performance budgets — Set thresholds for scores and resource sizes
- Historical tracking — Compare builds over time
- Variance reduction — Run multiple times, use median results
- GitHub integration — Status checks and PR comments
Quick Start
Install and run:
npm install -g @lhci/cli
lhci autorun --collect.url=https://example.com --upload.target=temporary-public-storage
Or with a config file (lighthouserc.js):
module.exports = {
ci: {
collect: {
url: ['https://example.com/'],
},
upload: {
target: 'temporary-public-storage',
},
},
}
Then run:
lhci autorun
How It Works
The lhci autorun command executes three steps:
- collect — Runs Lighthouse N times per URL
- assert — Checks results against budgets/assertions
- upload — Stores results (temporary storage, filesystem, or LHCI server)
Run lhci healthcheck --fatal separately to verify Chrome and config before autorun.
Results are saved to .lighthouseci/ locally.
What LHCI Measures
Lighthouse CI audits four categories on every run:
- Performance — Core Web Vitals (LCP, CLS, TBT as proxy for INP) and other speed metrics
- Accessibility — Screen reader support, color contrast, ARIA
- SEO — Meta tags, structured data, mobile-friendliness
- Best Practices — HTTPS, console errors, deprecated APIs
Each category gets a 0-100 score. Set thresholds in your config to block merges when scores drop.
Prerequisites
- Node.js 18+
- Chrome/Chromium installed
- A URL to test (can be localhost with
startServerCommand)
Tutorials
Related
- Core Web Vitals Guide — Understand the metrics LHCI tracks
- Bulk Lighthouse Testing — Test entire sites with Unlighthouse
- LCP Guide | CLS Guide | INP Guide
Performance Impact
Why invest in performance testing? Research shows direct business impact:
- BBC loses 10% of users for every additional second of load time
- Amazon estimates every 100ms of latency costs 1% in sales
- Google research shows bounce probability increases 90% as load time goes from 1s to 5s