How to use Lighthouse to audit and score page performance
Lighthouse performance score formula, opportunities vs diagnostics, Lighthouse CI, lighthouse-plugin-field-performance, throttling settings, score variability
Using Lighthouse Effectively
Lighthouse is an automated auditing tool built into Chrome DevTools. The performance score (0โ100) is a weighted average of six lab metrics. LCP and TBT (Total Blocking Time) carry the most weight.
Run Lighthouse from the command line for consistent, headless results:
npx lighthouse https://example.com \
--preset=desktop \
--output=html \
--output-path=./report.html \
--chrome-flags="--headless"Lighthouse reports two types of findings:
Opportunities โ actionable fixes with estimated savings (e.g., "Properly size images โ save 320KB")
Diagnostics โ contextual data without direct score impact (e.g., DOM size, main thread work)
Score variability is real: a score can fluctuate ยฑ5 points between runs due to CPU and network conditions. Always run at least 3 times and take the median. In CI, use thresholds, not exact scores:
// lighthouserc.js
module.exports = {
assert: {
assertions: {
'categories:performance': ['error', { minScore: 0.85 }],
'first-contentful-paint': ['warn', { maxNumericValue: 2000 }],
'largest-contentful-paint': ['error', { maxNumericValue: 2500 }]
}
}
};The most common Lighthouse trap: testing on a fast dev machine over a wired connection. Always use the simulated throttling (Mobile preset = 150ms RTT, 1.6Mbps) to represent median real-world conditions.
