Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 37 ยท Performance Budgets and Culture

Performance in CI and Team Culture

Automate performance checks with Lighthouse CI in pull requests, review third-party scripts, make speed visible, and build habits that keep a fast site fast.

Tools do not keep a site fast; habits do. The most successful teams make performance part of the normal workflow: it is checked automatically on every change, visible on a dashboard, and owned by someone. This lesson covers the technical side (CI checks) and the human side (culture).

Where to check

flowchart LR
  E["Editor<br/>lint, size hints"] --> PR["Pull request<br/>bundle size, Lighthouse CI"]
  PR --> ST["Staging<br/>synthetic tests"]
  ST --> PR2["Production<br/>RUM, alerts"]

The earlier a problem is caught, the cheaper it is to fix.

Pull request checks

Run cheap, fast checks on every pull request, and a heavier Lighthouse run for key pages:

  1. Bundle size with size-limit or the bundler's own limits.
  2. Lighthouse CI (LHCI): builds the site, starts it, runs Lighthouse several times per URL and asserts on scores, metrics and budgets.
  3. Image checks: a script that fails when a committed image exceeds a size.

A minimal lighthouserc.json:

JSON
{
  "ci": {
    "collect": {
      "startServerCommand": "npm run start",
      "url": ["http://localhost:3000/", "http://localhost:3000/products/1"],
      "numberOfRuns": 5
    },
    "assert": {
      "assertions": {
        "categories:performance": ["error", { "minScore": 0.85 }],
        "largest-contentful-paint": ["warn", { "maxNumericValue": 2500 }],
        "total-blocking-time": ["error", { "maxNumericValue": 300 }],
        "cumulative-layout-shift": ["error", { "maxNumericValue": 0.1 }]
      }
    },
    "upload": { "target": "temporary-public-storage" }
  }
}

And a GitHub Actions workflow to run it:

YAML
name: performance
on: pull_request
jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - run: npm ci && npm run build
      - run: npx @lhci/[email protected] autorun

(These files are read-only examples: they need a build and a CI runner, which the sandbox on this site does not have.)

Use error for rules you will really block a merge over and warn for rules you want to see but not block. If everything is an error, people stop trusting the check.

Fighting flaky results

Lab metrics vary. To avoid failing for noise:

  • Run each URL several times and assert on the median.
  • Use the same machine type and throttling in CI.
  • Compare against the previous main branch result (LHCI server can store history) rather than an absolute number alone.
  • Prefer stable assertions (bytes, request counts, TBT) over unstable ones (LCP on a shared runner).
JS Compare a PR to the main branch

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

No output.

Reviewing dependencies and third parties

A recurring review keeps the weight down:

  • Before adding a package: check its size, whether it tree-shakes, and whether the platform already offers the feature.
  • Every tag-manager tag needs an owner and an expiry date; delete what nobody can justify.
  • Load third-party scripts late and async; consider self-hosting stable ones.
  • Re-run a bundle analyzer monthly.

Making performance visible

What gets looked at gets fixed:

  • A dashboard of Core Web Vitals p75 by template, visible on a team screen.
  • A weekly report with the top regression and the top win.
  • A performance channel where alerts and PR check summaries land.
  • Include performance numbers in release notes.

Culture and process

  • Ownership. Name a person or small group who champions performance. Without an owner, it is everyone's second priority.
  • Definition of done. Add "meets performance budget" to the checklist for every feature.
  • Design involvement. Designers choose hero images, fonts, animations and widgets; show them the cost of each one in KB and milliseconds.
  • Product involvement. Tie speed to business results: show conversion or bounce rate by speed bucket.
  • Blameless learning. When a regression ships, write a short note on what check would have caught it, then add that check.
  • Training. Run a short lab session so everybody can read a waterfall and a flame chart.
JS Speed versus conversion

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

No output.

Numbers like these (from your own data) turn "performance" from a technical wish into a business case.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why should CI assert on the median of several Lighthouse runs?

    One run can be an outlier; the median is stable.
  2. 2. When should a CI assertion be an error instead of a warning?

    Too many blocking checks erode trust; reserve errors for rules that matter.
  3. 3. Which practice most helps keep third-party scripts under control?

    Ownership and expiry stop tags from piling up unnoticed.
  4. 4. What turns performance into a business argument?

    Linking speed to revenue helps prioritize performance work.

Summary

  • Check performance at several stages: in the editor, in pull requests, on staging and in production.
  • Use Lighthouse CI and size limits; assert on medians and distinguish errors from warnings.
  • Review dependencies and third-party tags regularly.
  • Make performance visible, owned and part of your definition of done.

Next: Project: Fix a Slow Page