Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 37 ยท Measuring and Monitoring

Lighthouse, PageSpeed and Lab Testing

Run Lighthouse and PageSpeed Insights correctly, read the score and the opportunities, control throttling and variance, and avoid common lab testing mistakes.

You cannot improve what you cannot measure. Lab testing means loading a page in a controlled environment (a fixed device profile, network speed and location) and recording what happens. Its big advantage is repeatability: you change one thing, test again and see the effect. This lesson covers the tools you will use every day: Lighthouse, PageSpeed Insights, WebPageTest and the DevTools throttling controls.

What Lighthouse does

Lighthouse is an open-source auditing tool built into Chrome DevTools (the Lighthouse panel), available as a CLI and as a Node module. It loads your page once in a simulated mobile or desktop profile and produces:

  • A Performance score from 0 to 100, which is a weighted blend of metrics: First Contentful Paint, Largest Contentful Paint, Total Blocking Time, Cumulative Layout Shift and Speed Index.
  • Opportunities and diagnostics: concrete suggestions such as "serve images in next-gen formats" or "reduce unused JavaScript", each with an estimated saving.
  • Other categories: Accessibility, Best Practices and SEO.
flowchart LR
  U["URL"] --> L["Lighthouse<br/>throttled load"]
  L --> M["Metrics<br/>FCP, LCP, TBT, CLS, SI"]
  M --> S["Score 0-100"]
  L --> O["Opportunities<br/>and diagnostics"]

The score is a summary; the opportunities are where the work is.

Lighthouse cannot measure Interaction to Next Paint, because it does not click anything during a standard run. It reports Total Blocking Time (TBT) as a lab stand-in. Use the user-flow mode (timespan and snapshot) to measure real interactions.

Running it

  1. DevTools: open an Incognito window (extensions distort results), open DevTools, choose the Lighthouse panel, pick Mobile and Performance, click Analyze page load.
  2. PageSpeed Insights (pagespeed.web.dev): paste a URL. It runs Lighthouse on Google's servers and also shows real-user field data for that URL if enough exists.
  3. CLI, ideal for scripts and CI:
Terminal
npm install -g lighthouse
lighthouse https://example.com --preset=desktop --output=json --output-path=./report.json

The CLI and DevTools use the same engine; the CLI makes it easy to run the test several times and automate it.

Throttling and why scores vary

A fast laptop on fast Wi-Fi hides problems that real users have. Lighthouse therefore simulates a slow phone: a 4x CPU slowdown and roughly "Slow 4G" network. Two methods exist:

  • Simulated throttling (default) loads the page quickly and models what would have happened on a slow connection. It is stable and fast.
  • Applied (DevTools) throttling really slows the browser. It is more literal but noisier.

Even with throttling, scores vary by a few points between runs because of server response time, CPU load on your machine, third-party content and A/B tests. Treat a single run as an estimate.

Reading the numbers

The median of several runs is much more trustworthy than one run. Here is a tiny helper that shows why:

JS Median beats a single run

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Run each test at least 5 times and compare medians. When you compare "before" and "after", change one thing at a time.

Scoring thresholds

Lighthouse colors scores: 90 to 100 green, 50 to 89 orange, 0 to 49 red. The score is non-linear: going from 40 to 60 is easier than from 90 to 100. Chasing a perfect 100 is rarely worth it; the goal is a good experience for real users, and the Core Web Vitals "good" thresholds are what matter for search.

JS Classify a metric

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Other lab tools

  • WebPageTest lets you pick real devices, locations and connection speeds and shows a detailed waterfall, filmstrip and request blocking. It is excellent for investigating why something is slow.
  • Chrome DevTools Performance panel records the main thread in detail (see the profiling lesson).
  • Lighthouse CI runs Lighthouse on every pull request (see performance in CI).

Common lab-testing mistakes

  • Testing only on your own fast machine with a warm cache. Test with a cold cache and mobile throttling.
  • Testing the home page only. Test the key templates: a product page, an article, a checkout.
  • Chasing the score instead of the user. Gaming Lighthouse (for example, delaying scripts until interaction) can raise the score while hurting real users.
  • Ignoring logged-in states. Lab tools test as an anonymous visitor.
  • Comparing numbers from different tools. Each has its own device profile; compare within one tool and one setup.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why does Lighthouse apply CPU and network throttling?

    Without throttling, a fast developer machine hides problems that real users experience.
  2. 2. Which metric does Lighthouse use in the lab as a stand-in for interactivity?

    Lighthouse does not click, so it reports TBT, which correlates with INP.
  3. 3. What is the best way to reduce the effect of run-to-run variance?

    The median ignores outliers caused by background load or network noise.
  4. 4. What is a danger of optimizing only for the Lighthouse score?

    The score is a proxy; real-user outcomes are the goal.

Summary

  • Lab tests are repeatable and ideal for debugging and verifying a change.
  • Lighthouse gives a weighted score plus opportunities; PageSpeed Insights adds field data.
  • Use throttling, test cold, run several times and compare medians.
  • Test several page types and do not optimize the score at the expense of users.

Next: The Performance API and Real-User Monitoring