Performance

perf/lighthouse-ci

Lighthouse in CI runs each URL several times, asserts on metrics and categories with realistic thresholds, and never demands a perfect 100.

minormanualfe-lighthouse

Why

A single Lighthouse run varies with CPU load, network and extensions, so a CI gate on one run fails at random and teaches people to ignore it. A gate at 100 is the same: the curve makes the last points almost unreachable and the score says nothing about real visitors.

Fix

Use @lhci/cli with numberOfRuns: 3 or more (the median is used), assert on the metrics that matter (largest-contentful-paint, cumulative-layout-shift, total-blocking-time) and on category scores with warn below and error well below your target, and test the URLs of each page type. Run on a dedicated, quiet runner; compare with the previous main build rather than an absolute number when you can.

Examples

{
  "ci": {
    "collect": { "url": ["http://localhost:4173/", "http://localhost:4173/pricing"], "numberOfRuns": 3 },
    "assert": { "assertions": {
      "categories:performance": ["warn", { "minScore": 0.9 }],
      "categories:accessibility": ["error", { "minScore": 0.95 }],
      "largest-contentful-paint": ["error", { "maxNumericValue": 2500 }],
      "cumulative-layout-shift": ["error", { "maxNumericValue": 0.1 }]
    } }
  }
}

Sources

Facts

Id
perf/lighthouse-ci
Severity
minor
Check
manual a person reviews it; the report lists it as a checklist
Applies to
project
Taught by the skill
fe-lighthouse Lighthouse and PageSpeed
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain perf/lighthouse-ci