Worked example · Performance

Hitting a web performance budget with WDD

A web performance budget (bundle size, Largest Contentful Paint, a Lighthouse score) is a clean WDD target if the measurement is scripted and repeated. The agent grinds through the changes; the person decides which trade-offs are allowed.

The goal

Bring the home page under 170 KB of JavaScript and a mobile Lighthouse performance score of at least 95, with the end-to-end tests green.

The verifier

A script that builds the site, measures the JavaScript size and runs Lighthouse three times, taking the median.

Why this check: The median of three runs smooths out noise; the size limit is exact.

The set-up

  • The budget as numbers in a file the verifier reads.
  • End-to-end tests for the main flows.
  • A list of things that must not be removed (analytics consent, accessibility features).

The kickoff prompt

Kickoff

Bring the home page within the budget in budget.json. Measure with scripts/perf.sh. Each round: find the largest cost, change one thing, measure, run the end-to-end tests. Never remove the features listed in AGENTS.md. Keep going until the budget is met.

How the rounds went

Rounds 1 to 3
A chart library loaded on every page is split out to the one page that uses it: 410 KB to 230 KB.
Rounds 4 to 8
Images get sizes and modern formats; a font loads with swap. Score 88 to 94.
Round 9
A third-party script moved to load after interaction. 168 KB, score 96, tests green.

What worked

  • A written list of what may not be cut.
  • Medians, not single runs.

What to watch for

  • Removing features is the fastest way to a good score. The list of protected features is what stops it.

Build a kit for a task like this

A worked example written to show the method, not a report of a specific project.

Questions people ask

Can the agent run Lighthouse itself?

Yes, from the command line in headless Chrome; the loop script runs it as part of the verifier.

More examples