Sub topic 11
Running and interpreting Lighthouse audits
This chapter assumes you can open DevTools and switch panels. It also assumes you have read the Network and Performance chapters, because Lighthouse reports many of the same measurements in summarized form. You should know what a render-blocking resource is, what a long task is, and how a browser requests and paints a page.
Lighthouse is an automated auditing tool built into Chromium-based DevTools. It loads a page under controlled conditions, collects data, and produces a report with scores and a list of findings. The report tells you where to look. It does not prove what is wrong, and it does not replace the panels you have already learned.
What Lighthouse measures
Lighthouse groups its audits into categories. Which ones appear depends on the version of Chrome you run.
| Category | What it checks | Typical findings |
|---|---|---|
| Performance | Load speed, main-thread work, layout stability | Large images, render-blocking CSS, long JavaScript tasks |
| Accessibility | Automated checks for assistive technology support | Missing alt text, low color contrast, unlabeled form fields |
| Best Practices | Security and modern web standards | Mixed content, deprecated APIs, console errors |
| SEO | Basic crawlability and metadata | Missing title or meta description, links without descriptive text |
Older versions also had a Progressive Web App category. Recent versions removed it, so do not be surprised if a tutorial or colleague mentions it and you cannot find it.
Accessibility audits cover only the checks that can be automated. A score of 100 does not mean the page is accessible. It means the page passed the checks a tool can run. Keyboard flow, sensible reading order, and meaningful link text still need manual testing.
Running an audit in DevTools
- Open the page you want to test. Use an incognito window if you can, so extensions do not add load or inject scripts.
- Open DevTools and select the Lighthouse panel. It may be hidden under the
>>overflow menu. - Choose a mode (see below), a device (Mobile or Desktop), and the categories to run.
- Click the button to analyze the page. Do not interact with the page while it runs, because Lighthouse reloads it and measures the result.
Modes
| Mode | What it does | Use it for |
|---|---|---|
| Navigation | Reloads the page and measures the full load | Load performance, the default choice |
| Timespan | Records while you interact with the already-loaded page | Layout shifts and blocking time during a user flow |
| Snapshot | Analyzes the page in its current state | Accessibility of a menu, dialog, or form that is open |
Navigation mode is the right choice for a first pass. Use Timespan when the problem happens after load, for example a layout jump when you open a filter. Use Snapshot for states a reload would destroy, such as an open modal.
Mobile versus Desktop
The device option changes two things. It sets the viewport and user agent, and it sets the throttling profile. Mobile applies a slower simulated CPU and network, which is why mobile scores are usually much lower than desktop scores for the same page. Test the device that matches your users. If most of your traffic is on phones, the Mobile result is the one that matters.
How the audit works internally
Lighthouse does not simply time your page on your machine. By default it loads the page at full speed and then uses a model to estimate how the load would have behaved on a slower device and network. This is called simulated throttling.
Simulated throttling has two consequences:
- Results are more repeatable than if Lighthouse applied real throttling during the load.
- The numbers can differ from what you see in the Performance panel with throttling enabled. Neither is wrong. They are different methods.
Reading the Performance score
The Performance score is a weighted average of five metric scores. In recent versions of Lighthouse the weights are:
| Metric | Measures | Weight |
|---|---|---|
| First Contentful Paint (FCP) | Time until the first text or image appears | 10% |
| Speed Index | How quickly the visible content fills in | 10% |
| Largest Contentful Paint (LCP) | Time until the largest visible element renders | 25% |
| Total Blocking Time (TBT) | Time the main thread was blocked by long tasks between FCP and interactivity | 30% |
| Cumulative Layout Shift (CLS) | Total unexpected movement of visible content | 25% |
Weights change between Lighthouse versions, so check the scoring calculator for the version you are running before you explain a score to someone else.
Scores are colored. 90 to 100 is green, 50 to 89 is orange, and 0 to 49 is red. Each metric is converted to a score by comparing it to a curve based on real-world data, so a faster metric gives diminishing returns near the top.
Three points follow from the weights:
- TBT and LCP carry more than half the score between them (55%), so JavaScript execution time and the load time of your main content usually matter most.
- TBT is a lab proxy for responsiveness. Lighthouse in navigation mode does not measure Interaction to Next Paint (INP), which needs real user input. If INP matters to you, use field data or a Timespan run with real interactions.
- CLS can be fixed cheaply in many cases, for example by giving images explicit
widthandheightattributes.
Opportunities, diagnostics and passed audits
Below the score, the report lists audits in groups. Learn the difference between them.
- Opportunities (called insights in recent versions) suggest changes with an estimated saving, such as "Reduce unused JavaScript" or "Properly size images." The saving is an estimate from the simulated load. It is not a guarantee.
- Diagnostics describe the page without an estimated saving, such as "Avoid enormous network payloads" or "Minimize main-thread work." They show where to dig, not what to change.
- Passed audits are collapsed by default. Open them when a result surprises you, because they confirm what is already working.
Expand any audit to see the specific URLs, elements, or lines involved. For an LCP audit, the report names the element, so you know what to optimize. A common mistake is to optimize the wrong image because you assumed which element was the LCP.
The View Treemap button, when shown, opens a map of your JavaScript bundles by size and unused bytes. It is useful for spotting one dependency that takes up most of a bundle.
Running Lighthouse from the command line
DevTools is convenient, but scripted runs are better for repeatable comparisons. The Lighthouse command-line tool needs Node.js and a Chrome installation.
npx lighthouse https://example.com \
--preset=desktop \
--only-categories=performance \
--output=json \
--output=html \
--output-path=./reportThis writes report.report.json and report.report.html in the current directory. Omit --preset=desktop to get the default mobile profile.
You can also drive Lighthouse from a Node.js script. This example needs npm install lighthouse chrome-launcher, and it must be saved as an ES module, for example audit.mjs.
import lighthouse from 'lighthouse';
import * as chromeLauncher from 'chrome-launcher';
const url = process.argv[2] ?? 'https://example.com';
const chrome = await chromeLauncher.launch({ chromeFlags: ['--headless'] });
try {
const result = await lighthouse(url, {
port: chrome.port,
output: 'json',
onlyCategories: ['performance'],
});
const { categories, audits } = result.lhr;
console.log('Performance score:', Math.round(categories.performance.score * 100));
for (const id of [
'first-contentful-paint',
'largest-contentful-paint',
'total-blocking-time',
'cumulative-layout-shift',
'speed-index',
]) {
console.log(`${audits[id].title}: ${audits[id].displayValue}`);
}
} finally {
await chrome.kill();
}Run it with node audit.mjs https://your-site.example. The script prints the score as a number from 0 to 100 and the five metric values. Because category scores in the result are stored from 0 to 1, the script multiplies by 100.
Why scores vary and how to get comparable results
Run Lighthouse three times on the same page and you will often get three different scores. The variance comes from things you can partly control:
- Machine load. A busy CPU slows the run. Close other applications and tabs.
- Extensions. They add requests and scripts. Use incognito or a clean profile.
- Network. Server response times and third-party scripts differ between runs.
- Dynamic content. Ads, A/B tests, and consent banners change what loads.
- Caching. DevTools clears storage by default before a navigation audit. If you disable that option, you measure a warm-cache load, which is not what a first-time visitor sees.
To compare a before and after change, run each version several times and compare the median, not a single result. Change one thing at a time so you know which change caused the difference. Treat a difference of a few points as noise.
Turning findings into fixes
The report is a starting point. A reliable approach is:
- Pick the metric that is worst relative to its weight. A red TBT is worth more attention than an orange Speed Index.
- Read the related audits. Poor LCP points you to the LCP element, image sizing, and render-blocking resources. Poor TBT points you to "Reduce JavaScript execution time" and "Minimize main-thread work."
- Confirm in the matching panel. Check network requests in the Network panel. Find long tasks in a Performance recording. Check heap growth in the Memory panel. Lighthouse tells you that something is slow, and the specialized panel tells you why.
- Make one change and rerun. Compare against your baseline.
Some common mappings:
| Finding | Likely cause | Where to confirm |
|---|---|---|
| High LCP | Slow server response, large hero image, render-blocking CSS | Network panel waterfall |
| High TBT | Large JavaScript bundles, heavy third-party scripts | Performance panel long tasks |
| High CLS | Images without dimensions, late-loading fonts or ads | Performance panel Layout Shifts track |
| Unused JavaScript | Libraries loaded on every page but used on one | Coverage tool and bundle treemap |
Common mistakes
- Chasing 100. A score of 100 is not the goal. Real users are. Stop when metrics are good for your audience.
- Testing only on your fast laptop with desktop settings. This hides problems that mobile users see.
- Auditing a page behind a login without handling the session. Lighthouse may test the login redirect instead of the page. Use DevTools while signed in, or script the flow with user-flow tooling.
- Fixing every opportunity. Savings are estimates and some changes cost more than they return. Start with the largest.
- Ignoring the Best Practices console errors. They often point at real bugs, such as failed requests or deprecated API use.
Exercise
You run a mobile Lighthouse audit three times. The Performance scores are 62, 71, and 66. You then change the page and get 74 in a single run. Can you conclude the change helped? What should you do next, and which metric should you check first if you want to improve the score the most?
Show answer
No. The single result of 74 is only slightly above the earlier range (62 to 71) and could be run-to-run variance. Run the audit several times for both the original and the changed page, using the same conditions (incognito, same device setting, no other load), and compare medians. To improve the score the most, look first at Total Blocking Time (30%) and then Largest Contentful Paint (25%), since they have the largest weights. Confirm the cause in the Performance and Network panels before changing code.
Exercise
A Lighthouse report shows a poor Cumulative Layout Shift. You open the page and it looks stable after loading. Which Lighthouse mode might expose the problem, and why?
Show answer
Timespan mode. The layout shift may happen during interaction or after a delayed event, such as a late-loading ad, a lazy-loaded image, or a menu opening. Timespan mode records while you use the loaded page, so it can capture shifts that a plain visual check after load misses. You can then confirm the shifting elements in the Performance panel's Layout Shifts track.