Which pages are fine on desktop but slow on mobile? Measure the PageSpeed gap per page

2026-12-02来源 dev.toEnglish

Most of us build and review sites on a laptop with a fast connection. The page feels quick, the desktop Lighthouse score is green, and the ticket gets closed. Then Search Console complains about mobile, or a customer on a mid-range phone says the product page takes forever.

A desktop score and a mobile score for the same page are two different tests. This post runs both on a list of pages, puts them side by side, and sorts by the gap, so you can see which pages are fine on desktop but slow on mobile, and which metric is to blame.

Why the two scores differ

The page is the same. The test conditions are not. For the mobile run, Lighthouse emulates a mid-range phone: a small viewport, a slowed-down CPU and a throttled network, roughly a slow 4G connection. The desktop run uses a large viewport, no CPU slowdown and a fast connection.

That means three things usually explain a gap:

  • JavaScript. Work that takes 100 ms on your laptop takes several times longer on the slowed-down CPU. It shows up as Total Blocking Time (TBT).
  • Payload. A large hero image or a render-blocking stylesheet costs little on a fast connection and a lot on a slow one. It shows up as Largest Contentful Paint (LCP).
  • A different layout. The mobile layout is often separate code: a different header, a banner that pushes content down, an image without reserved space. It shows up as Cumulative Layout Shift (CLS) on mobile only.

The thresholds also differ. Lighthouse scores mobile and desktop against separate curves, so a 1.5 second LCP is judged differently on each. Do not compare raw scores between sites; compare the gap between pages of one site.

Run both strategies

PageSpeed Insights Audit is an open-source Apify Actor that calls Google's official PageSpeed Insights API and returns one record per URL and strategy. Set Device strategy to Both and Categories to performance only, paste your pages into Page URLs, and click Start. Or send this input (placeholder domain):

{ "urls": [ "https://www.yoursite.example/", "https://www.yoursite.example/pricing/", "https://www.yoursite.example/product/brass-desk-lamp/", "https://www.yoursite.example/blog/choosing-warm-light/" ], "strategy": "both", "categories": ["performance"] } 

Pick pages the way you would for any sweep: two or three from each template (home, listing, detail, article, landing page) rather than fifty of the same kind.

Each page comes back as two records, one with "strategy": "mobile" and one with "strategy": "desktop". The fields used below (trimmed):

{ "url": "https://www.yoursite.example/pricing/", "strategy": "mobile", "success": true, "scores": { "performance": 83 }, "labMetrics": { "lcpMs": 4351, "cls": 0, "tbtMs": 49 } } 

Pair the records and sort by the gap

Export the dataset as JSON and save it as audits.json. The script pairs the two records for each URL, computes desktop score minus mobile score, and names any metric that is over Lighthouse's "good" line on mobile (LCP 2.5 s, TBT 200 ms, CLS 0.1) while still under it on desktop.

import json from collections import defaultdict records = json.load(open("audits.json", encoding="utf-8")) by_url = defaultdict(dict) for r in records: if r.get("success"): by_url[r["url"]][r["strategy"]] = r def cause(m, d): """Name the lab metric that is over the 'good' line on mobile but fine on desktop.""" mm, dm = m["labMetrics"], d["labMetrics"] hits = [] if (mm["tbtMs"] or 0) > 200 and (dm["tbtMs"] or 0) <= 200: hits.append("TBT (JavaScript)") if (mm["lcpMs"] or 0) > 2500 and (dm["lcpMs"] or 0) <= 2500: hits.append("LCP (payload)") if (mm["cls"] or 0) > 0.1 and (dm["cls"] or 0) <= 0.1: hits.append("CLS (mobile layout)") return ", ".join(hits) or "-" rows = [] for url, pair in by_url.items(): m, d = pair.get("mobile"), pair.get("desktop") if not m or not d: continue ms, ds = m["scores"]["performance"], d["scores"]["performance"] if ms is None or ds is None: continue rows.append((ds - ms, url, ms, ds, m, d)) rows.sort(key=lambda r: -r[0]) print(f"{'gap':>4}{'mob':>5}{'desk':>5}{'LCP m/d (s)':>14}{'TBT m/d (ms)':>15} {'mobile-only problem':<28}url") for gap, url, ms, ds, m, d in rows: mm, dm = m["labMetrics"], d["labMetrics"] lcp = f"{(mm['lcpMs'] or 0)/1000:.1f}/{(dm['lcpMs'] or 0)/1000:.1f}" tbt = f"{mm['tbtMs'] or 0:.0f}/{dm['tbtMs'] or 0:.0f}" print(f"{gap:>4}{ms:>5}{ds:>5}{lcp:>14}{tbt:>15} {cause(m, d):<28}{url}") 

What a real run looks like

I ran this on 10 public pages from five well-known sites on 2 December 2026 (20 audits, about two minutes). The numbers below are from that run; I have replaced the URLs with labels, because one lab run is not a fair verdict on anyone's site.

 gap mob desk LCP m/d (s) TBT m/d (ms) mobile-only problem url 22 78 100 1.5/0.4 0/0 CLS (mobile layout) site A, category page 15 83 98 4.4/1.1 49/0 LCP (payload) site B, downloads page 10 78 88 1.7/0.4 6/0 - site A, home 2 98 100 0.9/0.2 0/0 - site C, home 0 100 100 1.4/0.4 0/0 - site D, home 0 100 100 1.1/0.3 0/5 - site E, article 0 100 100 0.8/0.2 4/0 - example.com -2 100 98 1.1/1.1 4/0 - site E, home -5 89 84 3.5/1.0 0/0 LCP (payload) site B, home -54 100 46 1.1/0.4 17/2324 - site D, article 

Read the table

Start at the top and stop when the gap gets small. A difference of five points or fewer is within normal run-to-run noise.

  • Row 1, gap 22, CLS. Nothing is slow here: LCP is 1.5 s and TBT is zero. The whole gap is layout shift that happens only in the mobile layout. No amount of image compression would fix this page. Open it in DevTools with a phone viewport and watch what moves while it loads.
  • Row 2, gap 15, LCP. The largest element takes 4.4 s on the throttled connection and 1.1 s on the fast one. This is a payload problem: look at the size of the LCP image, whether it is lazy-loaded by mistake, and what blocks rendering before it. Turn on Include audit details for this page and the record lists the opportunities with estimated savings.
  • Row 3, gap 10, no flag. Mobile CLS was high here too, but so was desktop CLS, so it is not a mobile-only problem and the script leaves the column empty. The page has a layout shift on every device; fix that first, then re-measure the gap.
  • Second to last row. LCP is flagged, but the gap is negative: the desktop score is lower. The flag only says mobile LCP crossed 2.5 s. Read the gap first and the flag second.
  • Last row, gap -54. Desktop scored 46 with 2.3 seconds of blocking time; mobile scored 100. I would not trust that from one run. A single lab run can catch a third-party script or a busy test machine at a bad moment. Run that URL again before believing it, and treat any single surprising number the same way.

Notice what did not appear: none of these ten pages had a TBT problem on mobile. On script-heavy sites (single-page apps, pages with tag managers, chat widgets and A/B testing tools) that column is usually where the gap comes from, and the fix is less or later JavaScript, not smaller images.

Lab is not field

Everything above is lab data: one simulated load. It tells you where to look. It does not tell you what your visitors get. Real phones vary, and plenty of them are faster than Lighthouse's emulated one.

Each record also carries fieldData when Google has enough real-user Chrome data for the page: the 75th-percentile LCP, INP and CLS for that device type. Before spending a sprint on a mobile gap, check the mobile record's fieldData.overallCategory. If the lab gap is large but the field data says FAST, the problem is real but less urgent than it looks. If the field data agrees with the lab, you have your priority list.

Cost and limits

The Actor charges a flat $0.004 per successfully audited page and strategy.

  • Both strategies means two audits per page. 30 pages is 60 audits: 60 x $0.004 = $0.24.
  • Re-running the three or four surprising pages to rule out noise costs a few cents more.
  • Invalid URLs, pages Google cannot load and quota errors come back with success: false and cost nothing, and a run stops at the maximum cost you set.

Limits to plan around:

  • Public pages only. Google must be able to fetch the page, so pages behind a login or on a private staging host fail.
  • Lab scores move a few points between runs. Compare gaps of ten points or more, and re-run outliers.
  • By default the Actor uses a built-in Google API key shared by all its users. When the quota runs out you get free rate-limited records; retry later or paste your own free key into Google API key.

If this saves you time, a review on the Store page helps other people find it, and a star on GitHub helps too.

Disclosure: I built this Actor. Source: github.com/josh99smith/pagespeed-insights-audit. PageSpeed Insights and Lighthouse are Google trademarks; the Actor is not affiliated with Google.

原文:https://www.a8q9.cn/en/article/which-pages-are-fine-on-desktop-but-slow-on-mobile-measure-the-pagespeed-gap-per-11f6a9.html

相关文章