Lighthouse CI: Continuous Integration Performance Testing
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):
export default {
ci: {
collect: {
url: ['https://example.com/'],
},
upload: {
target: 'temporary-public-storage',
},
},
}
Then run:
lhci autorun
Setting Up Lighthouse Continuous Integration
Getting Lighthouse into your CI pipeline takes four steps: install @lhci/cli, add a config file with your URLs and budgets, wire it into your CI workflow (GitHub Actions, GitLab CI, etc.), and optionally connect the LHCI server for historical tracking. The tutorials below walk through each platform in detail.
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
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
Resources
Redirects
Eliminate redirect chains that delay LCP. Learn to identify and fix 301/302 redirects, canonical URL issues, and trailing slash mismatches.
GitHub Actions
Complete Lighthouse CI GitHub Actions documentation. Step-by-step YAML workflows, status checks, PR comments, and treosh/lighthouse-ci-action setup.