# Performance budget enforced in build

- **Pattern:** `ab-002044` (`performance-deep-dive.regression-prevention.performance-budget-enforced`)
- **Severity:** low
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-002044
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-002044)

## Why it matters

Without an enforced performance budget, bundle size drifts upward with each feature addition. A new charting library here, a heavier date picker there — after six months, your initial bundle has grown from 200KB to 600KB with no single commit being obviously culpable. ISO 25010:2011 time-behaviour captures the gradual degradation; an enforced budget makes the growth visible immediately, when a single PR pushes past the threshold, rather than during a quarterly performance audit.

## Severity rationale

Low because performance budget enforcement is a preventive control — its absence does not immediately degrade performance, but allows gradual regression to accumulate undetected across multiple PRs.

## Remediation

Add `size-limit` to your project and configure it with a 250KB threshold for the initial JavaScript bundle. Wire it into your CI pipeline so PRs fail if they exceed the budget.

```json
// .size-limit.json
[
  {
    "path": ".next/static/chunks/pages/index-*.js",
    "limit": "250 KB",
    "gzip": true
  }
]
```

In `package.json` scripts: `"size": "size-limit"`, then add `npm run size` to your CI workflow after `npm run build`.

## Detection

- **ID:** `performance-budget-enforced`
- **Severity:** `low`
- **What to look for:** Count all build config files. Enumerate any bundle size budget settings (size-limit, webpack performance hints). Check build config for bundle size budget settings. Look for webpack-bundle-analyzer with size warnings, or tools like `size-limit`. Verify build fails if bundle exceeds budget.
- **Pass criteria:** Performance budget is defined (e.g., max bundle size 250KB) and enforced. Build fails if budget is exceeded. Budget documented in repo. At least 1 budget defined with maximum 250KB for the initial bundle.
- **Fail criteria:** No performance budget defined, or budget is not enforced (doesn't fail build).
- **Skip (N/A) when:** Never — budgets help prevent gradual performance degradation.

- **Cross-reference:** For Lighthouse CI enforcement in CI/CD, see `lighthouse-ci-configured`.
- **Detail on fail:** `"No bundle size budget configured"` or `"Budget defined as 500KB but not enforced — build succeeds even if bundle grows to 750KB"`
- **Remediation:** Configure size-limit or webpack bundle analyzer with budget enforcement.

  ```json
  // .size-limit.json — enforce bundle budget
  [{ "path": ".next/static/chunks/*.js", "limit": "250 KB", "gzip": true }]
  ```

## External references

- iso-25010 time-behaviour

Taxons: operational-readiness, performance

HTML version: https://auditbuffet.com/patterns/ab-002044
