Agustin Barrientos
All posts

A Higher Lighthouse Score Doesn't Mean a Faster Interface

Want more of these in your Google results?

A page can go from 69 to 99 in Lighthouse while leaving every click after it loads just as slow as before. You can’t use a higher performance score as proof that a pull request fixed slow clicks. The score comes from one test load on an emulated phone, where nothing ever clicks a button.

PageSpeed Insights and the Lighthouse panel in Chrome DevTools both get that score from Lighthouse.

Lighthouse scores the product page below at 99 in its default mobile run.

Click ⁠Add to cart⁠ a few times fast.

The cart count changes about a third of a second after each click. Nielsen Norman Group says responses need to take less than 0.1 seconds to feel instant, and that people start noticing delays after 0.2 seconds.

Google tracks that delay with one of its three Core Web Vitals. They measure how a page loads, responds to input, and stays still on screen during real visits from Chrome users. Google reports them in Search Console and uses them in its ranking systems.

Google’s guide to its performance tools says to focus on the Core Web Vitals over Lighthouse scores, since the performance score “often does not correlate” with them.

And slow responses are common. HTTP Archive puts out a yearly report on the state of the web called the Web Almanac. Its 2025 performance chapter uses Chrome’s data per origin (a site’s address without the path, like https://example.com).

About 1 in 4 mobile origins weren’t rated “good” for responding to input. More than half failed at least one of the Core Web Vitals.

In this article I’ll review a pull request that says it fixes slow clicks on this product page, and find out which of its two commits raised the score and which one made the click faster.

The pull request with the fix

Help me review this pull request.

The pull request is called “Speed up the product page on phones”. The description has “Closes #412.”, the two commit messages, and one line on the mobile Lighthouse score going from 69 to 99. It doesn’t mention how the score was measured.

Issue #412 comes from PageSpeed Insights. Besides running Lighthouse, PageSpeed Insights shows data from real Chrome users who visited a page. The product page fails the Core Web Vitals assessment there on mobile, because its measurement for responding to clicks isn’t good.

That measurement is the time from a click, a tap, or a key press until the browser paints the next frame. Google calls it Interaction to Next Paint, or INP. For each visit, it’s usually the time of the slowest one, since INP only skips one outlier for every 50 interactions. A visit with no click, tap, or key press has no INP at all.

The first commit is “Split the startup work into small tasks”. On load, the product page’s script renders the recommended products further down the page, all in one go.

Your JavaScript and the page’s clicks share one thread, the main thread. Anything that keeps it busy for more than 50 ms is called a long task.

With this commit, the script stops between products and lets the browser handle clicks and paint. It does that by awaiting yieldToMain(), a small helper like the one in web.dev’s guide to long tasks.

product-page.js
// product-page.js
-addEventListener( 'load', () => {
+addEventListener( 'load', async () => {
 	for ( const product of recommendations ) {
 		renderCard( product );
+		await yieldToMain();
 	}
 } );

The product page in the first demo, at the top of the article, already has this commit, but not the next one.

Next comes the second commit, “Update the cart count before the cart work”. Without it, the ⁠Add to cart⁠ handler changes the count last, after updating the cart summary and sending an analytics event.

Now the handler changes the count first and waits for the browser to paint it, with another small helper called nextPaint(). Then it runs the rest of the cart work in small steps from cartSteps() and awaits yieldToMain() between them. web.dev’s guide to optimizing INP uses the same pattern.

product-page.js
// product-page.js
- $addToCart.addEventListener( 'click', () => {
+ $addToCart.addEventListener( 'click', async () => {
    cart.add( product );
-   updateCartSummary();
-   trackAddToCart( product );
    $cartCount.textContent = cart.count;
+   await nextPaint();
+   for ( const step of cartSteps( product ) ) {
+     step();
+     await yieldToMain();
+   }
 } );

Each step has to stay under 50 ms, or it’s a long task that a second click waits for. In the demos, the startup work and the cart work are stand-ins that keep the main thread busy for a fixed 1,000 ms and 300 ms. This commit turns the cart work into 30 steps of 10 ms.

On a pull request like this, where both changes share one number in the description, I start by asking what that number measured, and whether that’s what the pull request says it fixed.

Where the 99 comes from

Lighthouse’s performance score combines five measurements of the page load, with Total Blocking Time weighing the most, at 30%. It adds up how far each long task goes past 50 ms, from the moment the first text or image shows up until the page settles.

Without the pull request, that’s the only measurement that’s off. On load, the product page renders its recommended products in one task that takes about a second. Lighthouse’s emulated phone is four times slower, which turns that task into about four seconds of blocking.

The first commit cuts that task into pieces of 10 ms. Even on the slower phone, none of them gets past 50 ms, which takes Total Blocking Time to 0 and the score from 69 to 99. The work is all still there, though, just split up.

The second commit only changes the code that runs when you click ⁠Add to cart⁠. Lighthouse never clicks anything in that test. That’s why the second commit can’t move the score at all.

Turn on each commit with the switches in the report below.

Each report is the median of nine Lighthouse runs with the mobile defaults on /demos/vitals-page, one set of runs per version.

The score went from 69 to 99 on the first switch and stayed at 99 on the second. Going by the score alone, only the first commit seems to matter. But with just the first commit, a click on ⁠Add to cart⁠ still takes about a third of a second, the same as in the first demo. This report comes from Lighthouse’s default mode. That mode can’t show the faster click from the second commit. Lighthouse has another mode that can, which I’ll get to below.

The click

web.dev’s article on Total Blocking Time describes it as a number from test runs that can hint at INP, but not a replacement for measuring INP itself. So you have to measure the click.

DevTools’ Performance panel measures clicks in a view called live metrics. It fills that view with web-vitals, Google’s JavaScript library for measuring the Core Web Vitals. In the demo below, there’s a drawing of that view under the product page. For each click it logs, it shows how much of the time went to waiting for the main thread (input delay) and how much to running the click handler (processing duration).

Click ⁠Run demo⁠. Once the photo has been up for a couple of seconds, click ⁠Add to cart⁠ a few times. Do the same each time you turn on a commit, since every switch reloads the page.

Without the second commit, a click a couple of seconds after the page loads takes a little over 300 ms, nearly all of it processing duration. That number doesn’t change with the first commit. Once ⁠Include commit 2: Cart count first⁠ is on, the count changes right away and INP goes down to a few tens of milliseconds or less.

The first commit does help one kind of click, though. A click made while the startup work runs has to wait for it to finish. With the first commit, INP for an early click drops from 1,176 ms to 320 ms.

Table What each version measures in Lighthouse and on a click.
VersionLighthouse scoreTotal Blocking TimeINP after startupINP during startup
Before the pull request693,880 ms328 ms1,176 ms
First commit only990 ms328 ms320 ms
Second commit only693,880 ms48 ms872 ms
Both commits990 ms48 ms24 ms
Sources: nine default mobile Lighthouse runs per version for the score and Total Blocking Time, and web-vitals with DevTools’ settings in Chromium for INP, five runs per cell, all medians, with the early click 150 ms into the startup work.

I’d approve the first commit as a fix for clicks during startup.

The other Lighthouse mode I mentioned is called a timespan. Instead of one load, it records what happens while you use the page, clicks included. Compare INP in the timespan report below as you turn the commits on and off.

Each report is the median of five timespans that click "Add to cart" three times, one second apart.

With the second commit, INP dropped from about 330 ms to 30 or 40 ms. Nothing changed with the first commit alone. Total Blocking Time moved with the second commit here, from 760 ms to 0 ms, since the timespan counts the long tasks from its three clicks.

I’d ask for that INP, with and without the pull request, in its description next to the score.

The 28-day window

Issue #412 comes from field data (the numbers from real visits).

PageSpeed Insights gets its field data from the Chrome UX Report (CrUX). CrUX counts visits from Chrome users who share usage statistics and sync their history, on public sites with enough traffic. For every metric, it reports the 75th percentile of the page loads in a 28-day period that ends a couple of days before the report.

If the product page got 100 visits with a click, the 75th percentile is the 75th INP time when you sort them from fastest to slowest. Three out of four visits were that fast or faster. Only the slowest quarter took longer. For INP to pass, that time has to be 200 ms or less.

So on merge day, the fix can’t lower the reported 75th percentile yet, because every visit in the 28-day window is from before the deploy.

Drag the slider in the drawing below to see what PageSpeed Insights shows for the product page, day by day, from the day the fix ships.

The visits are example data from a model with 1,000 page loads a day, each with a click, and one INP distribution before the fix and another after it.

Once at least three out of four visits with a click in the window take 200 ms or less, INP passes. After about 28 days, the window has nothing but visits to the fixed page. That’s why I’d take “Closes #412” out of the description and keep the issue open until PageSpeed Insights shows the fix.

Search Console’s Core Web Vitals report uses CrUX data too, from the same 28 days.

web.dev’s guide to finding slow interactions points out that CrUX shows you have a problem, but not what’s causing it. Data you collect yourself with web-vitals covers Safari and Firefox too, and lets you look at the visits since the deploy without mixing them with the ones before it. You also see which part of a slow click takes the time.

Other ways to get a 99

Some WordPress plugins hold back all JavaScript until the first interaction. WP Rocket’s docs list Total Blocking Time among the PageSpeed recommendations that setting helps with. Perfmatters’ docs warn that the click delay “might be longer than desired” on a big site, and suggest turning on ⁠Disable Click Delay⁠ to protect INP.

The score goes up, but the first click waits for the JavaScript to load and run.

Some pages detect Lighthouse and serve it a lighter page. Mateusz Krzeszowiak from Shopify listed how they do it in a Lighthouse issue, like looking for “Lighthouse” or “moto g power” (the phone Lighthouse emulates) in the user agent. He wrote on Shopify’s performance blog that if your own field data shows slower speeds than the testing tool, “you might have a performance hack on your site.” I’d block any code like that in review.

What separates a senior from a junior here

  • Lighthouse’s docs say to use the median of several runs, since scores vary from one run to the next even with no code change. Ask for the medians with the pull request and without it.
  • A click that’s slow on a mid-range phone can look fine on a laptop. Measure it with CPU throttling turned on in the Performance panel, and check it against the page’s CrUX numbers in live metrics.
  • Even when INP passes, up to a quarter of the page’s INP times can be over 200 ms. Use your own web-vitals data to find which clicks and pages they come from.

Want more of these in your Google results?