DEV Community

Cover image for A Lighthouse Best Practices sweep: console errors, deprecated APIs and third-party cookies across your pages
Joshua Smith
Joshua Smith

Posted on

A Lighthouse Best Practices sweep: console errors, deprecated APIs and third-party cookies across your pages

Best Practices is the Lighthouse category people read last. It sits between Accessibility and SEO, it is usually in the 90s, and the checks have names like inspector-issues that do not say much.

But it is the category that catches things nobody on the team sees: JavaScript errors that only happen on some devices, a browser API that Chrome has announced it will remove, a tag manager quietly setting dozens of third-party cookies, or a page that asks for the visitor's location the moment it loads. None of these look broken in your own browser.

This post runs only the Best Practices category on a list of pages, groups the failing checks by what they mean, and adds the few security header checks that the score does not cover.

What the category checks

The scored checks, grouped the way I find useful:

  • Privacy and permissions: third-party-cookies (cookies set by other domains, which Chrome is restricting), geolocation-on-start and notification-on-start (permission prompts on page load, before the visitor has done anything), paste-preventing-inputs (fields that block pasting, usually password fields).
  • Will break in a future browser: deprecations, which lists browser APIs Chrome has marked for removal.
  • Errors: errors-in-console (JavaScript errors and failed requests logged while the page loaded), inspector-issues (the Issues panel in Chrome DevTools: cookie problems, mixed content, blocked resources), valid-source-maps.
  • Rendering: doctype (no <!DOCTYPE html>, so the browser falls back to quirks mode), charset, image-aspect-ratio (images displayed stretched or squashed), image-size-responsive (images too low-resolution for the screen).
  • Security: is-on-https.

What it does not score: the security headers. Lighthouse reports Content-Security-Policy, HSTS, clickjacking protection and origin isolation as informational checks with no weight, so they never move the number. There is a quick way to check those at the end of this post.

Run the Best Practices category only

PageSpeed Insights Audit is an open-source Apify Actor that calls Google's official PageSpeed Insights API and returns one record per URL. Set Lighthouse categories to Best practices only, turn on Include audit details so each record lists the failing checks, and paste your pages into Page URLs. Or send this input (placeholder domain):

{
    "urls": [
        "https://www.yoursite.example/",
        "https://www.yoursite.example/pricing/",
        "https://www.yoursite.example/blog/",
        "https://www.yoursite.example/blog/choosing-warm-light/",
        "https://www.yoursite.example/product/brass-desk-lamp/"
    ],
    "strategy": "mobile",
    "categories": ["best-practices"],
    "includeAuditDetails": true
}
Enter fullscreen mode Exit fullscreen mode

Pick two or three pages per template, plus any page that loads a different set of scripts: the checkout, a page with an embedded video or map, a landing page with a chat widget. Third-party scripts cause most Best Practices failures, so the pages with the most of them are the ones to include.

Each record comes back like this (trimmed):

{
    "url": "https://www.yoursite.example/",
    "strategy": "mobile",
    "success": true,
    "scores": { "bestPractices": 54 },
    "failedAudits": [
        {
            "id": "deprecations",
            "title": "Uses deprecated APIs",
            "category": "best-practices",
            "score": 0,
            "displayValue": "3 warnings found"
        },
        {
            "id": "third-party-cookies",
            "title": "Uses third-party cookies",
            "category": "best-practices",
            "score": 0,
            "displayValue": "4 cookies found"
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

Group the failures by what they mean

Export the dataset as JSON and save it as best-practices.json. The script sorts every failing check into a group, lists the pages under each, then prints the scores and the pages that could not be audited.

import json
from collections import defaultdict

records = json.load(open("best-practices.json", encoding="utf-8"))

# Lighthouse Best Practices checks, grouped by what they mean for you.
GROUPS = {
    "Security": ["is-on-https"],
    "Privacy and permissions": ["third-party-cookies", "geolocation-on-start",
                                "notification-on-start", "paste-preventing-inputs"],
    "Will break in a future browser": ["deprecations"],
    "Errors": ["errors-in-console", "inspector-issues", "valid-source-maps"],
    "Rendering": ["doctype", "charset", "image-aspect-ratio",
                  "image-size-responsive", "js-libraries"],
}
group_of = {check: g for g, checks in GROUPS.items() for check in checks}

by_group = defaultdict(lambda: defaultdict(list))
scores, not_audited = [], []
for r in records:
    if not r.get("success"):
        not_audited.append((r["url"], r.get("errorType")))
        continue
    scores.append((r["scores"]["bestPractices"], r["url"]))
    for a in r.get("failedAudits", []):
        if a["category"] != "best-practices":
            continue
        g = group_of.get(a["id"], "Other")
        by_group[g][a["id"]].append((r["url"], a.get("displayValue") or ""))

for g in list(GROUPS) + ["Other"]:
    if g not in by_group:
        continue
    print(f"== {g} ==")
    for check, pages in sorted(by_group[g].items(), key=lambda kv: -len(kv[1])):
        print(f"  {len(pages):>2}  {check}")
        for url, detail in pages:
            print(f"        {url}  {detail}".rstrip())

print("\n== Scores, lowest first ==")
for score, url in sorted(scores):
    print(f"  {score:>3}  {url}")

print("\n== Not audited (free, check by hand) ==")
for url, err in not_audited:
    print(f"  {err:<12} {url}")
Enter fullscreen mode Exit fullscreen mode

Any check the script does not know lands under "Other", so a new Lighthouse check shows up instead of disappearing.

What a real run looks like

I ran this on 12 public pages from eleven sites on 4 December 2026 (mobile, Best Practices only, under a minute). As in the earlier posts in this series, I have replaced the site names with labels: the point is the shape of the output, not grading anyone's site.

== Privacy and permissions ==
   2  third-party-cookies
        site D, news front  4 cookies found
        site J, home  34 cookies found
   1  geolocation-on-start
        site H, directory
== Will break in a future browser ==
   2  deprecations
        site D, news front  3 warnings found
        site J, home  1 warning found
== Errors ==
   3  errors-in-console
        site D, news front
        site G, front
        site J, home
   3  inspector-issues
        site D, news front
        site F, guide
        site J, home
== Rendering ==
   1  image-aspect-ratio
        site B, docs home
   1  doctype
        site E, front page
   1  image-size-responsive
        site H, directory

== Scores, lowest first ==
   54  site D, news front
   54  site J, home
   92  site H, directory
   96  site B, docs home
   96  site E, front page
   96  site F, guide
   96  site G, front
  100  example.com
  100  site A, home
  100  site C, home

== Not audited (free, check by hand) ==
  http-error   site I, portal
  http-error   site I, article
Enter fullscreen mode Exit fullscreen mode

Read the output

  • The two 54s fail the same four checks. Both are ad-supported media front pages, and both fail third-party cookies, deprecations, console errors and DevTools issues. That pattern almost always means the failures come from third-party scripts (ads, analytics, consent tools, embeds), not from the site's own code. The fix starts with an inventory: which vendors load on this template, and does each one still earn its place?
  • 34 third-party cookies on one home page. Chrome restricts third-party cookies for a growing share of users, so anything that depends on them (retargeting, some embedded logins, cross-site analytics) is already failing for part of your audience. The count is also a privacy question your consent banner should be able to answer.
  • Deprecated APIs. "3 warnings found" means three APIs Chrome has announced it will remove. Today they work; after the removal they throw or silently do nothing. The full Lighthouse report in PageSpeed Insights names each API and the script that called it. If it is your code, fix it now while it is calm; if it is a vendor's, check whether they have shipped an update you are not loading.
  • Console errors on three pages. A JavaScript error during load can mean a broken feature on some devices only, which is exactly the kind of bug no one on the team reproduces. Open the page on a phone-sized viewport with DevTools open, or read the details in the full report.
  • Asking for location on page load. Site H's directory page requests the geolocation permission before the visitor does anything. Browsers increasingly hide or auto-deny prompts like that, and visitors tend to say no to a prompt they did not expect. Ask after a click on something like "Use my location" instead.
  • Quirks mode. Site E's front page has no doctype, so the browser renders it in quirks mode. It is an old, deliberately simple page and it works, but on a modern site a missing doctype can change box sizing and spacing in surprising ways. It is a one-line fix in the layout template.
  • The two pages that were not audited. PageSpeed Insights returned a server error (HTTP 500) for both pages on site I, which happens with some sites and is not the Actor's doing. Those records were free. Re-run them later or test them by hand in Chrome DevTools.

Add the header checks the score leaves out

Because the security headers carry no weight, a page can score 100 with no Content-Security-Policy, no HSTS and no protection against being framed. A HEAD request shows them:

curl -sI https://www.yoursite.example/ | grep -i -E 'strict-transport|content-security|x-frame|cross-origin-opener'
Enter fullscreen mode Exit fullscreen mode

In the run above, the plain example.com page scored 100 and returned none of these four headers, while site A, also at 100, sent CSP, HSTS and X-Frame-Options. Same score, very different setups. Which headers you need depends on the site, but you should know which ones you have.

Make it part of the release check

Third-party scripts change without a deploy on your side, so this sweep is worth running on a schedule, not only after releases. A weekly run in Apify Console on two or three pages per template is enough. To alert only on changes that matter, keep last week's results and compare:

WATCH = {"deprecations", "errors-in-console", "geolocation-on-start",
         "notification-on-start", "is-on-https"}

def failing(records):
    return {(r["url"], a["id"]) for r in records if r.get("success")
            for a in r.get("failedAudits", []) if a["id"] in WATCH}

old = failing(json.load(open("last-week.json", encoding="utf-8")))
new = failing(records)
for url, check in sorted(new - old):
    print(f"NEW  {check:<22} {url}")
Enter fullscreen mode Exit fullscreen mode

A new deprecation warning or console error between two weekly runs, with no deploy of your own in between, usually points straight at a vendor script update.

Cost and limits

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

  • The 12-page run above had 10 successful audits: 10 x $0.004 = $0.04.
  • A weekly check of 30 template pages costs $0.12 a run, about $0.50 a month.
  • Pages Google cannot load, invalid URLs 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's test machine loads the page as a first-time visitor with no cookies, so it sees the consent banner state and scripts of a new visitor, not a logged-in user's.
  • One load, one device profile. A console error that only happens after a click, or only on a slow connection, will not show up.
  • With Include audit details, failedAudits holds up to 15 failing checks per page across the selected categories. With Best Practices alone, the worst page here had four.
  • 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.

Top comments (0)