Performance Budget
Establishes quantitative performance targets for frontend and backend systems — including Core Web Vitals, API latency budgets, bundle size limits, and CI gates that prevent performance regression.
Guiding Principle
"Performance is a feature. A budget is a commitment. A regression gate is a guarantee."
Procedure
Step 1 — Baseline Current Performance
- Measure current Core Web Vitals: LCP, FID/INP, CLS for key pages.
- Profile API latency at p50, p95, p99 for critical endpoints.
- Audit frontend bundle sizes: total, per-route, vendor vs. application code.
- Measure Time to Interactive (TTI) and Total Blocking Time (TBT) on target devices.
- Establish baseline metrics in a shared dashboard for ongoing tracking.
Step 2 — Define Performance Budgets
- Core Web Vitals: LCP < 2.5s, INP < 200ms, CLS < 0.1 (Google "Good" thresholds as minimum).
- API Latency: Define per-endpoint p99 budgets based on user experience requirements.
- Bundle Size: Total JS < 200KB gzipped for initial load; per-route chunks < 50KB.
- Time to Interactive: < 3.5s on mid-range mobile (Moto G4 equivalent) over 4G.
- Image Budgets: Total image weight per page, format requirements (WebP/AVIF), lazy loading policy.
Step 3 — Implement Regression Gates
- Add bundle size checks to CI: fail PR if total bundle exceeds budget by > 5%.
- Integrate Lighthouse CI for automated Core Web Vitals checks on PRs.
- Set up API latency regression tests: fail if p99 increases by > 20% from baseline.
- Configure performance monitoring alerts for production regressions.
- Create a performance budget dashboard showing trend lines and budget utilization.
Step 4 — Optimize and Maintain
- Conduct quarterly performance audits with updated baselines.
- Review and adjust budgets based on business needs and user demographics.
- Document optimization techniques applied and their measured impact.
- Create a performance optimization backlog prioritized by user impact.
- Tag all budget decisions with evidence and rationale.
Quality Criteria
- Every critical page has defined Core Web Vitals budgets with measurement methodology.
- Bundle size budgets are enforced in CI with clear pass/fail criteria.
- API latency budgets are per-endpoint with p99 targets.
- Performance regression is detected before code reaches production.
Anti-Patterns
- Setting performance budgets without measuring the current baseline.
- Measuring only on fast developer machines instead of target user devices.
- Bundle size limits that are never enforced in CI.
- Optimizing for Lighthouse score instead of real user experience.