Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 37 ยท Performance and Lighthouse

Lighthouse Audits for PWAs

Audit a PWA with Lighthouse and DevTools: how to run it, what the performance score weighs, reading opportunities, installability checks, CI budgets and lab versus field data.

Lighthouse is an open-source auditing tool built into Chrome DevTools. It loads a page under controlled conditions, measures it, and produces a report with scores and concrete fixes. For PWAs it is the quickest way to find problems with speed, accessibility, security and best practices, and it can run automatically on every commit.

One thing changed that older tutorials get wrong: Lighthouse used to have a "PWA" category with a badge. It was removed in Lighthouse 12 (2024). Installability and offline behavior are now checked in the DevTools Application panel and by your own tests, while Lighthouse focuses on four categories. This lesson shows how to use all of these together.

Running Lighthouse

There are four ways to run it:

  1. Chrome DevTools: open DevTools, choose the Lighthouse tab, pick Mobile, select categories and press Analyze.
  2. PageSpeed Insights: enter a public URL and get a Lighthouse run plus real-user data from the Chrome UX Report.
  3. Command line: npx lighthouse https://example.com --view.
  4. Lighthouse CI: run it in your pipeline and compare results over time.

Run audits in an incognito window with extensions disabled; extensions add scripts and skew scores. Run it several times: results vary by around five points between runs.

The categories

  • Performance: how fast the page loads and becomes interactive.
  • Accessibility: contrast, labels, names for buttons and images, keyboard and screen reader basics. Automated checks find only a portion of real problems, so test by hand too.
  • Best Practices: HTTPS, no console errors, no deprecated APIs, correct image aspect ratios.
  • SEO: crawlable links, meta description, <title>, valid robots.txt.

How the performance score is built

The score from 0 to 100 is a weighted mix of lab metrics (weights from Lighthouse 10 and later):

Metric Weight
Total Blocking Time 30%
Largest Contentful Paint 25%
Cumulative Layout Shift 25%
First Contentful Paint 10%
Speed Index 10%

Each metric is converted to its own 0 to 1 score by comparing it with real-world data curves, then the weighted average is shown. Green is 90 and above, orange 50 to 89, red below 50. Notice that blocking JavaScript (TBT) is the largest single factor.

JS Reproduce a performance score

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

No output.

The exercise shows why chasing one metric blindly is inefficient: improve the heaviest-weighted metric that is currently lowest.

Reading a report

Under the scores, Lighthouse lists:

  • Opportunities: changes with an estimated saving in seconds, such as "Reduce unused JavaScript" or "Properly size images".
  • Diagnostics: information without a direct time estimate, such as "Avoid an excessive DOM size" or "Minimize main-thread work".
  • Passed audits: collapsed list of what already works.
  • Treemap: a view that shows which scripts and modules make up your bundle; a fast way to spot a heavy dependency.

Work from the top: fix what shows the biggest saving, re-run, repeat.

Checking PWA features without the PWA category

Use DevTools, Application panel:

  • Manifest: shows parsing errors, icons, and an Installability section listing exactly what blocks installation.
  • Service workers: status, update on reload, offline checkbox, push and sync test fields.
  • Storage / Cache storage: inspect what the worker has cached and how much space you use.
  • Network tab with "Offline" throttling: reload and confirm the app still loads.

The installability criteria Chromium checks are well defined, and you can describe them in code:

JS An installability checklist

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

No output.

Chromium no longer strictly requires a service worker with a fetch handler to install on some platforms, but the manifest, icons and HTTPS requirements remain, and a service worker is still the way to get offline support. See installability for how the prompt works.

Lab data versus field data

Lighthouse is lab data: one simulated device (mid-tier phone, throttled 4G), one load, no user interaction. It is repeatable and perfect for finding causes. Field data (real users) shows what people actually experience and includes INP, which Lighthouse cannot measure without interaction. Use both: field data to find out whether there is a problem, lab data to find out why.

Automating with Lighthouse CI

Running the audit in your pipeline stops regressions. A configuration file sets assertions:

JSON
{
  "ci": {
    "collect": { "url": ["http://localhost:8080/"], "numberOfRuns": 3 },
    "assert": {
      "assertions": {
        "categories:performance": ["error", { "minScore": 0.9 }],
        "categories:accessibility": ["error", { "minScore": 0.95 }],
        "largest-contentful-paint": ["warn", { "maxNumericValue": 2500 }]
      }
    }
  }
}

numberOfRuns: 3 takes the median, which smooths the random variance. Treat failures as build failures, so slowdowns are fixed while the change is still fresh.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What changed about Lighthouse and PWAs in recent versions?

    Lighthouse 12 removed the PWA category; installability is inspected in DevTools' Application panel.
  2. 2. Which metric carries the biggest weight in the performance score?

    TBT has a 30% weight, more than any other single metric.
  3. 3. Why might Lighthouse report good results while real users suffer?

    Field data covers real devices, networks and interactions (INP) that a single lab run does not.
  4. 4. Why set numberOfRuns to 3 in Lighthouse CI?

    Single runs vary; the median of several is more stable.

Summary

  • Run Lighthouse in incognito, on mobile settings, several times; use PageSpeed Insights for field data too.
  • The score is a weighted mix of TBT, LCP, CLS, FCP and Speed Index.
  • Fix opportunities in order of estimated saving; the treemap finds heavy dependencies.
  • Check manifest, installability, worker and cache in the DevTools Application panel.
  • Enforce scores in CI with Lighthouse CI.

Next: Loading and Resource Hints