Performance Budgets
Performance budgets are limits for resource sizes and metrics that help maintain fast load times. Setting and enforcing budgets prevents performance regression over time.Recommended Resource Budgets
| Resource Type | Budget | Rationale |
|---|---|---|
| Total page weight | < 1.5 MB | 3G network loads in ~4s. Keeps LCP under 2.5s for median mobile users |
| JavaScript (compressed) | < 300 KB | Parsing + execution time impact on TBT/INP. Each 100KB adds ~1s on low-end mobile |
| CSS (compressed) | < 100 KB | Render blocking resource. Larger CSS delays First Contentful Paint |
| Images (above-fold) | < 500 KB | Direct impact on LCP. Above-fold images must load quickly |
| Fonts | < 100 KB | FOIT/FOUT prevention. Excessive font files block text rendering |
| Third-party | < 200 KB | Uncontrolled latency. Third-party scripts often load additional resources |
Budget Breakdown by Page Type
Landing Pages
Focus on fast initial impression:E-commerce Product Pages
Balance visuals with performance:Content/Blog Pages
Prioritize text readability:Web Applications
Allow for interactive features:Metric Budgets
Core Web Vitals
| Metric | Budget | Based On |
|---|---|---|
| LCP | < 2.5s | Google’s “Good” threshold (75th percentile) |
| INP | < 200ms | Google’s “Good” threshold |
| CLS | < 0.1 | Google’s “Good” threshold |
| FCP | < 1.8s | Fast First Contentful Paint |
| TBT | < 200ms | Low Total Blocking Time |
Network Metrics
| Metric | Budget | Based On |
|---|---|---|
| TTFB | < 800ms | Time to First Byte on 4G |
| DOM Content Loaded | < 1.5s | Document ready state |
| Load Event | < 3s | All resources loaded |
Size Metrics
| Metric | Budget | Based On |
|---|---|---|
| Number of Requests | < 50 | HTTP/2 mitigates, but more = more processing |
| Main Thread Work | < 2s | Keeps TBT low |
| JavaScript Execution Time | < 1s | Allows for fast interactions |
Measuring Against Budgets
Using Lighthouse CLI
Using Webpack Bundle Analyzer
Using bundlesize
Using Chrome DevTools
-
Network Panel:
- View total transferred size
- Filter by resource type
- Check individual file sizes
-
Coverage Panel:
- Identify unused CSS/JS
- See code utilization percentage
- Find opportunities to reduce bundle
-
Performance Panel:
- Measure Core Web Vitals
- Analyze main thread work
- Identify long tasks
Enforcing Budgets
CI/CD Integration
GitHub Actions Example:Webpack Performance Hints
Next.js Bundle Analysis
Optimizing to Meet Budgets
JavaScript Budget Exceeded
Solutions:- Implement code splitting
- Remove unused dependencies
- Use tree-shaking
- Lazy load non-critical features
- Replace heavy libraries with lighter alternatives
CSS Budget Exceeded
Solutions:- Remove unused CSS
- Use critical CSS inlining
- Split CSS by route
- Use CSS-in-JS for component-scoped styles
- Minimize specificity and duplication
Image Budget Exceeded
Solutions:- Compress images (use WebP/AVIF)
- Implement lazy loading
- Use responsive images with srcset
- Serve correctly sized images
- Use CDN with automatic optimization
Font Budget Exceeded
Solutions:- Use variable fonts (one file for all weights)
- Subset fonts to required characters
- Preload critical fonts only
- Use font-display: swap or optional
- Consider system font stack
Third-Party Budget Exceeded
Solutions:- Defer non-critical third-party scripts
- Self-host when possible
- Use facade pattern for embeds
- Lazy load analytics
- Review necessity of each third-party
Monitoring Budgets Over Time
Tools
- Lighthouse CI: Continuous monitoring in CI/CD
- SpeedCurve: Performance monitoring with budget alerts
- Calibre: Performance budgets with regression detection
- WebPageTest: One-off testing with detailed metrics
- Google Search Console: Core Web Vitals field data
Setting Up Alerts
Create alerts when budgets are exceeded:Budget Examples by Industry
News/Media
- Total: 1.5 MB (image-heavy)
- Focus on LCP for hero image
- Lazy load article images
SaaS Dashboard
- Total: 2.5 MB (initial), 500 KB (route change)
- Code splitting by route essential
- Focus on INP for interactions
E-commerce
- Total: 1.5 MB
- Balance product images with speed
- Optimize for mobile shoppers
Corporate/Marketing
- Total: 1 MB
- Fast LCP critical for conversions
- Minimal JavaScript
Additional Resources
- web.dev - Performance Budgets
- Lighthouse Performance Budgets
- Can I Use… Data - Browser usage for budget planning