Performance Budget Calculator

Set a target page weight and calculate how much you can spend on JavaScript, CSS, Images, and Fonts.

A performance budget is a limit you set on the size of your web pages. Without a budget, websites inevitably suffer from "feature creep," becoming bloated and slow over time. This ruins your Web Performance and Core Web Vitals.

Interactive Budget Calculator

Enter your target total page weight (in kilobytes) to generate a recommended budget breakdown. A good starting target for a fast mobile experience is 1000 KB (1 MB).

KB
HTML
50 KB
5%
CSS
50 KB
5%
JavaScript
200 KB
20%
Fonts
100 KB
10%
Images/Media
600 KB
60%

How the Budget is Calculated

The calculator uses standard industry ratios for resource allocation:

  • Images (60%): Images are visually important but relatively cheap for the browser to process. Most of your budget should go here.
  • JavaScript (20%): JS is the most "expensive" byte on the web because it must be executed. Keeping this budget strict is crucial for interactivity.
  • Fonts (10%): 1-2 optimized, subsetted web fonts usually fit within this budget.
  • HTML (5%): The structure of your page. Should rarely exceed 50KB.
  • CSS (5%): If using modern utility frameworks or critical CSS, 50-100KB is plenty.

Enforcing the Budget

A budget is useless if it isn't enforced. You should integrate performance budgeting directly into your CI/CD pipeline.

Lighthouse CI

You can configure Lighthouse CI to fail your build if certain budgets are exceeded:

// lighthouserc.json
{
  "ci": {
    "assert": {
      "budgetsFile": "budget.json"
    }
  }
}
// budget.json
[
  {
    "resourceSizes": [
      { "resourceType": "script", "budget": 200 },
      { "resourceType": "image", "budget": 600 }
    ]
  }
]

Webpack Performance Hints

If you use Webpack, you can set it to throw warnings or errors during the build process:

// webpack.config.js
module.exports = {
  // ...
  performance: {
    hints: "warning", // or "error"
    maxEntrypointSize: 250000, // 250kb
    maxAssetSize: 250000
  }
};

Frequently Asked Questions

What is a performance budget?

A performance budget is a set of limits imposed on metrics that affect site performance. This usually takes the form of maximum file sizes (e.g., max 200KB of JavaScript, 500KB of images) to ensure the site remains fast as new features are added.

Why is JavaScript budgeted differently than images?

Byte for byte, JavaScript is much more expensive than images. An image only needs to be downloaded and decoded. JavaScript must be downloaded, parsed, compiled, and executed on the main thread, which blocks interactivity and drains battery life.

How do I enforce a performance budget?

You can enforce budgets using CI/CD tools. For example, Lighthouse CI or Webpack performance hints can automatically fail a build or block a pull request if the new code exceeds the defined budget limits.