Back to blog

Performance Budgets and Real User Monitoring: Making Speed Stick

Optimizing once is easy; staying fast is the hard part. Budgets in CI plus field monitoring turn performance from a project into a property of the codebase.

Continuous integration pipeline reporting performance results

Almost every team has done a performance sprint. Scores go green, everyone celebrates, and six months later the site is slow again. Nothing went wrong in particular — a tag here, a library there, a carousel on the homepage. Speed decays by default because nothing is defending it.

A budget is a number someone has to argue with

A performance budget is a limit written in a file and enforced automatically. Three kinds are worth having:

  • Resource budgets — "the article page ships at most 170KB of compressed JavaScript and 400KB total". Easy to measure, hard to argue with.
  • Metric budgets — "LCP under 2.5s on a simulated mid-range phone".
  • Count budgets — "no more than three third-party origins". This one catches the slow creep of tags nobody owns.

Enforce them in CI so exceeding a budget fails the build, and make the failure message say which file grew. A budget that only produces a dashboard nobody reads will be ignored within a month.

Build pipeline showing a failing performance check
A budget only works when crossing it blocks something.

Lab numbers lie, politely

Synthetic tests are reproducible, which makes them great for catching regressions and terrible for describing reality. They run from one location, on one device profile, with a warm cache and no browser extensions. Your users have none of that.

That is what real user monitoring is for. Ship the web-vitals library, collect LCP, INP and CLS from actual sessions, and send them to your analytics with a few dimensions attached: page template, device category, connection type, country. The goal is not an average. It is the 75th percentile, segmented — because "the site is fast except on Android in one region" is an actionable sentence and "average LCP is 2.1s" is not.

Attribution is what makes RUM useful

Collecting a bad INP value tells you little. Collecting it along with the element that was interacted with and the longest script that ran tells you what to fix. The attribution build of the web-vitals library does this, and it is the difference between a number and a task.

A workable routine

  1. Set budgets from your current numbers, not from an ideal. If you ship 300KB today, set 310KB and ratchet down.
  2. Run synthetic checks on every pull request for the three or four templates that matter.
  3. Review field data monthly, segmented by template and device.
  4. When a regression appears, find the commit through the budget report rather than bisecting by hand.
  5. Give third-party scripts an owner and an expiry date. Unowned tags are how sites get slow.
Performance Budgets and Real User Monitoring: Making Speed Stick — 1Performance Budgets and Real User Monitoring: Making Speed Stick — 2Performance Budgets and Real User Monitoring: Making Speed Stick — 3
Written by

Hesam Ziaee, a web developer and programmer who builds fast, user-friendly websites with Vue.js, Quasar and Node.js.