Перейти к содержимому
Skip to content
← All articles

Web Performance Budgets: Setting, Enforcing, and Automating Performance Limits

What Is a Performance Budget?

A performance budget is a set of quantifiable limits on metrics that affect user experience. These limits act as guardrails, preventing performance regressions from reaching production. Unlike aspirational performance goals, budgets are enforced — builds that exceed them fail, pull requests get flagged, and teams are alerted before degradation ships.

Performance budgets transform performance from a reactive concern into a proactive engineering discipline. They make trade-offs explicit: adding a new feature or dependency requires fitting within the budget or making room by optimizing elsewhere.

Choosing the Right Metrics

Effective performance budgets combine multiple metric types to cover different aspects of user experience:

Milestone Metrics

Quantity-Based Metrics

Rule-Based Metrics

Setting Budget Thresholds

Setting the right thresholds requires balancing ambition with practicality. Here is a proven methodology:

  1. Baseline your current performance. Run Lighthouse and WebPageTest on your key pages. Record all metrics across desktop and mobile profiles.
  2. Benchmark against competitors. Test your top 3-5 competitors with the same tools. Your budget should aim to be at least 20% faster than the fastest competitor on critical metrics.
  3. Account for user conditions. Test on mid-tier devices (Moto G Power) with throttled 4G connections. This represents the experience of your median mobile user.
  4. Set initial budgets at current baseline. Prevent things from getting worse before trying to make them better. Then tighten gradually — reduce budgets by 10-15% per quarter.
  5. Define budgets per page template. Homepage, product pages, and checkout flows have different performance profiles and should have separate budgets.

Performance Budget Configuration

Here is an example budget configuration file that can be used with Lighthouse CI or similar tools:

{
  "budgets": [
    {
      "path": "/*",
      "timings": [
        { "metric": "largest-contentful-paint", "budget": 2500 },
        { "metric": "first-contentful-paint", "budget": 1800 },
        { "metric": "cumulative-layout-shift", "budget": 0.1 },
        { "metric": "interactive", "budget": 3500 }
      ],
      "resourceSizes": [
        { "resourceType": "script", "budget": 300 },
        { "resourceType": "total", "budget": 1500 },
        { "resourceType": "third-party", "budget": 100 }
      ],
      "resourceCounts": [
        { "resourceType": "total", "budget": 50 },
        { "resourceType": "script", "budget": 15 }
      ]
    }
  ]
}

CI/CD Integration

Automated enforcement in the CI/CD pipeline is where performance budgets deliver the most value. Without automation, budgets are just suggestions.

Lighthouse CI

Lighthouse CI runs audits against every pull request and fails builds that exceed budgets:

# .lighthouserc.json
{
  "ci": {
    "collect": {
      "url": ["http://localhost:3000/", "http://localhost:3000/product"],
      "numberOfRuns": 3
    },
    "assert": {
      "assertions": {
        "largest-contentful-paint": ["error", { "maxNumericValue": 2500 }],
        "cumulative-layout-shift": ["error", { "maxNumericValue": 0.1 }],
        "resource-summary:script:size": ["error", { "maxNumericValue": 307200 }]
      }
    },
    "upload": {
      "target": "temporary-public-storage"
    }
  }
}

Bundlesize and Size-Limit

For JavaScript bundle budgets specifically, tools like size-limit provide fast, accurate checks:

# package.json
{
  "size-limit": [
    { "path": "dist/app.js", "limit": "150 KB" },
    { "path": "dist/vendor.js", "limit": "120 KB" },
    { "path": "dist/**/*.css", "limit": "50 KB" }
  ]
}

Enforcement Tools Comparison

ToolMetric TypesCI IntegrationPR Comments
Lighthouse CITiming, size, scoreGitHub Actions, GitLab CIYes
size-limitBundle size, load timeAny CIYes (with action)
bundlewatchBundle sizeAny CIYes
SpeedCurveAll (RUM + synthetic)API документацию-basedSlack/webhook

Maintaining Budgets Over Time

Conclusion

Performance budgets are the most effective mechanism for preventing performance regressions at scale. By choosing the right metrics, setting realistic thresholds, and enforcing them through CI/CD automation, teams can maintain fast user experiences even as applications grow in complexity. Start with a few critical metrics, automate enforcement, and expand coverage over time.

Check your website right now

Check now →
More articles: Performance
Performance
Image Optimization for Web Performance
14.03.2026 · 16 views
Performance
Content Delivery Optimization: CDN Strategies and Edge Computing
16.03.2026 · 11 views
Performance
API Performance Metrics and Optimization
14.03.2026 · 10 views
Performance
Latency vs Throughput: Understanding Network Performance Metrics
16.03.2026 · 18 views