Skip to main content

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.

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

Network Metrics

Size Metrics


Measuring Against Budgets

Using Lighthouse CLI

budget.json:

Using Webpack Bundle Analyzer

Using bundlesize

Using Chrome DevTools

  1. Network Panel:
    • View total transferred size
    • Filter by resource type
    • Check individual file sizes
  2. Coverage Panel:
    • Identify unused CSS/JS
    • See code utilization percentage
    • Find opportunities to reduce bundle
  3. Performance Panel:
    • Measure Core Web Vitals
    • Analyze main thread work
    • Identify long tasks

Enforcing Budgets

CI/CD Integration

GitHub Actions Example:
lighthouserc.js:

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