Most PageSpeed work happens one page at a time: someone runs the home page, fixes what Lighthouse lists, then moves to the next page and finds the same list. On a real site, most of the weight comes from things every page shares: the header template, a web font, a CSS bundle, a tag manager, a hero image component. Fix one of those and twenty pages improve. This post audits a sample of pages from one site, counts which opportunities repeat, and ranks them so the shared causes come first.

Why the page-by-page list misleads

A Lighthouse report is about one page. It ranks opportunities by the estimated saving on that page, so a large image on one blog post can outrank a render-blocking stylesheet that slows every page a little. It cannot tell you that the stylesheet is on every page, because it has seen only one.

The estimates also need care. Each savingsMs is Lighthouse's guess at how much faster one metric would get if you fixed that audit alone, on a simulated device. Audits overlap: unused CSS sits inside the render-blocking stylesheet, so fixing one shrinks the other. Two runs of the same page differ. So the numbers are good for putting fixes in order and bad for promising "this saves 3.2 seconds". Never add savings across audits.

Pick the pages by template

Twenty to fifty pages is enough. More pages from the same template add little; one page from each template adds a lot. List the templates your site has (home, category or listing, product or service, article, landing page, search, contact and legal pages) and take several of each, favouring the ones with the most traffic. Your analytics top-pages report or the sitemap is a good source.

Audit mobile first; Google Search ranks with mobile data, and mobile savings are larger because the test device is slower. Add desktop if your audience is mostly desktop.

Run the audits

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. With Include audit details on, each record carries opportunities[] (failing performance audits with savingsMs and savingsBytes, largest first, up to 15) and failedAudits[] (failing accessibility, best-practices and SEO audits, up to 15). Paste the pages into Page URLs, switch on Include audit details and click Start, or send this input (placeholder domain, trimmed):

{ "urls": [ "https://www.yoursite.example/", "https://www.yoursite.example/about/", "https://www.yoursite.example/products/", "https://www.yoursite.example/products/widget-pro/", "https://www.yoursite.example/blog/", "https://www.yoursite.example/blog/how-we-test/", "https://www.yoursite.example/contact/" ], "strategy": "both", "includeAuditDetails": true } 

From the API, with the JSON saved as input.json:

curl -X POST "https://api.apify.com/v2/acts/josh99smith~pagespeed-insights-audit/run-sync-get-dataset-items?token=$APIFY_TOKEN" \ -H "Content-Type: application/json" -d @input.json -o results.json 

Each audit takes Google 10 to 30 seconds, so 50 pages on both strategies takes several minutes. Synchronous endpoints suit short runs; for a longer list start the run in the Console and download the dataset as JSON.

Aggregate and rank with a script

For each strategy the script counts how many pages each opportunity fails on, takes the median savingsMs across those pages, and ranks by median savings x pages affected. The median keeps one heavy page from dominating; multiplying by pages puts shared problems first. An audit failing on 80% or more of pages is marked shared; otherwise the script names up to three of the pages. It then counts failing accessibility, best-practices and SEO audits by pages affected. Pages that redirected to another host are left out, since they are not this site's template. Save it as fixes.py; it needs Python 3.8 or later and no packages.

import json import sys from collections import defaultdict from statistics import median from urllib.parse import urlparse SHARED = 0.8 # an audit failing on this share of pages or more is probably one shared cause records = json.load(open(sys.argv[1], encoding="utf-8")) host = lambda u: urlparse(u).hostname or "" SITE = sys.argv[2] if len(sys.argv) > 2 else host(records[0]["url"]) pages, offsite, failed = defaultdict(set), set(), [] opps = defaultdict(lambda: defaultdict(list)) # strategy -> audit id -> [(page, ms, bytes)] audits = defaultdict(lambda: defaultdict(set)) # strategy -> (category, audit id) -> {page} titles = {} for r in records: if not r["success"]: failed.append(f"{r['url']} ({r['errorType']})") continue if host(r["finalUrl"]) != SITE: # redirected away: not this site's template offsite.add(f"{r['url']} -> {r['finalUrl']}") continue s, page = r["strategy"], r["url"] pages[s].add(page) for o in r.get("opportunities", []): titles[o["id"]] = o["title"] opps[s][o["id"]].append((page, o["savingsMs"] or 0, o["savingsBytes"] or 0)) for a in r.get("failedAudits", []): titles[a["id"]] = a["title"] audits[s][a["category"], a["id"]].add(page) for s in sorted(pages): n = len(pages[s]) rows = [] for aid, hits in opps[s].items(): ms = median(h[1] for h in hits) kb = median(h[2] for h in hits) / 1024 rows.append((ms * len(hits), kb * len(hits), aid, len(hits), ms, max(h[1] for h in hits), kb, hits)) rows.sort(reverse=True) print(f"\n{SITE} {s}: {n} pages. Opportunities ranked by median savings x pages affected") print(f"{'#':>2} {'audit':34} {'pages':>7} {'median ms':>9} {'max ms':>7} {'median KiB':>10} {'score':>7}") for i, (score, kbscore, aid, k, ms, mx, kb, hits) in enumerate(rows, 1): tag = "shared" if k / n >= SHARED else ", ".join(sorted(urlparse(h[0]).path for h in hits)[:3]) print(f"{i:>2} {aid[:34]:34} {k:>3}/{n:<3} {ms:>9.0f} {mx:>7} {kb:>10.0f} {score / 1000:>6.1f}s {tag}") print(f"\n{SITE} {s}: failing accessibility, best-practices and SEO audits by pages affected") for (cat, aid), hit in sorted(audits[s].items(), key=lambda kv: -len(kv[1]))[:10]: print(f" {len(hit):>3}/{n:<3} {cat:15} {aid}") print("\nScores are Lighthouse estimates per page; overlapping audits share savings, so never add rows.") print("Redirected off the site (excluded):", "; ".join(sorted(offsite)) or "none") print("Not audited:", "; ".join(failed) or "none") 

Run python fixes.py results.json, or python fixes.py results.json www.yoursite.example to name the host yourself. The titles dictionary holds the readable audit titles if you want them in the output.

Read the result

On a test run of 22 pages of a well-known public site (host replaced), the mobile table started like this:

www.yoursite.example mobile: 20 pages. Opportunities ranked by median savings x pages affected # audit pages median ms max ms median KiB score 1 render-blocking-insight 20/20 1500 1500 0 30.0s shared 2 unused-css-rules 20/20 710 900 130 14.2s shared 3 unused-javascript 20/20 300 450 59 6.0s shared 4 unminified-css 20/20 150 150 24 3.0s shared 5 cache-insight 19/20 150 300 0 2.9s shared 6 redirects 1/20 751 751 0 0.8s /old-page/ 7 font-display-insight 15/20 50 150 0 0.8s /, /about/, /about/team/ 

Two of the 22 pages redirected to other hosts and were excluded. The top four rows are almost certainly one cause: a large stylesheet loaded in the <head> of every page, unminified and mostly unused on any given page. That is one ticket for the template, not twenty tickets. The redirect on one page has a high per-page saving but affects one page, so it ranks below the shared work, which is the point. The second table showed seven accessibility audits failing on 20 of 20 pages, which points at the shared navigation markup.

The dataset tells you which audit repeats, not which file causes it. Open two or three of the affected pages in pagespeed.web.dev or Lighthouse in Chrome DevTools and expand the audit; if the same stylesheet, font or third-party script is listed each time, you have found the shared cause. Then re-audit the same pages after the fix and compare. The score column is for ordering only; read it as "this matters most", not as seconds you will gain.

Two more cautions. The Actor keeps the top 15 opportunities per page, so on very slow pages a small audit can drop off the list and the page counts become a lower bound. And lab results move by a few points between runs; for a decision that matters, run the sample twice and check the order holds.

Cost and limits

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

  • The test run above was 22 pages x 2 strategies = 44 audits: 44 x $0.004 = $0.176. Pages that redirect still count as audited.
  • A 50-page sample on both strategies is 100 audits, $0.40. Running it again after the fix is another $0.40.
  • 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 with http-error.
  • By default the Actor uses a built-in Google API key shared by all its users: 25,000 requests a day and a few hundred a minute. When it runs out you get free rate-limited records; retry later or paste your own free key into Google API key.
  • Concurrency defaults to 4. With your own key, 6 to 8 is a sensible maximum before per-minute quota errors.

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.