A frontend performance budget turns vague goals such as “make the app faster” into release checks that developers can measure. This reusable template gives you starting thresholds for JavaScript, CSS, images, fonts, requests, and loading metrics, plus a practical workflow for testing them locally, in CI, and after deployment.
Overview
A performance budget is a limit that a page or feature should not exceed. Budgets can cover transferred bytes, resource counts, execution time, or real-user loading outcomes. They are most useful when they are attached to a page type, device profile, and release decision rather than treated as a single global number for an entire product.
The table below is a reasonable starting point for a content-heavy or SaaS web application. These are engineering targets, not universal laws or replacements for field data. Adjust them after measuring your product, audience, framework, and hosting environment.
| Budget area | Starting target for a mobile profile | What to measure |
|---|---|---|
| Initial JavaScript | Keep the critical route near or below 170 KB compressed | Route-level transfer size and main-thread execution |
| Initial CSS | Keep critical CSS near or below 50 KB compressed | Critical and total stylesheet transfer |
| Images | Keep above-the-fold images near or below 300 KB combined | Displayed images, format, dimensions, and transfer size |
| Fonts | Prefer one family and limited weights; target about 100 KB initially | Font files requested before meaningful content |
| Requests | Target roughly 50 or fewer initial requests where practical | Document, scripts, styles, images, fonts, and third-party calls |
| LCP | Internal target: 2.5 seconds or better | Largest Contentful Paint in field and controlled tests |
| INP | Internal target: 200 milliseconds or better | Interaction latency, especially after hydration |
| CLS | Internal target: 0.1 or lower | Unexpected layout movement during the page lifecycle |
Do not assume that passing a byte budget guarantees a fast experience. A small JavaScript bundle can still block the main thread, and a page with few requests can still have a slow server response or poorly prioritized hero image. Use resource budgets and user-facing metrics together.
How to estimate
Start by defining the page or route being evaluated. A marketing homepage, authenticated dashboard, checkout flow, and documentation page have different content and interaction needs. Create a separate budget when a route has a materially different job or loading pattern.
- Choose a device profile. Begin with a constrained mobile profile for the strictest release gate, then add a desktop profile if desktop behavior differs significantly.
- List the critical path. Identify the document, critical CSS, route JavaScript, fonts, hero media, and data requests needed before the first useful interaction.
- Set a total allowance. Add the desired limits for JavaScript, CSS, images, fonts, and other resources. Leave explicit room for analytics, experiments, error reporting, and future features.
- Measure both transfer and execution. Record compressed transfer size, uncompressed size where relevant, parse and execution time, request count, and loading milestones.
- Make the result actionable. A failed budget should identify the route, resource type, change from the base branch, and likely owner. A red number without a diagnostic is not a useful release control.
A simple allocation formula is:
route budget = platform overhead + product features + resilience margin
For example, if a route has a 170 KB JavaScript budget and platform overhead consumes 55 KB, the feature code and dependencies have 115 KB available. Keep a margin rather than allocating every byte; otherwise normal maintenance will turn small additions into recurring regressions.
For JavaScript, measure each route separately instead of relying only on the largest bundle. Check for duplicate dependencies, unshakable libraries, oversized polyfills, and modules loaded before they are needed. For images, estimate displayed dimensions first, then select a responsive source and modern format appropriate to the content. A large original upload should not become the default mobile payload.
Inputs and assumptions
Write the assumptions beside every budget so a future developer can tell whether a failure represents a real regression or a changed test. At minimum, record:
- Route: URL, application state, authentication state, and representative content.
- Network: connection profile, latency, caching behavior, and whether the test is cold or warm.
- Device: processor profile, viewport, memory assumptions, and browser version.
- Build: production mode, minification, compression, source maps, feature flags, and environment variables.
- Data: realistic response sizes and API timing rather than empty fixtures.
- Third parties: consent state and the external scripts or widgets included in the tested experience.
Use browser performance APIs and an audit tool for local investigation, but do not treat a single synthetic run as field truth. Browser APIs can expose navigation timing, resource timing, paint timing, layout shifts, and interaction timing. Repeat controlled tests, compare a baseline commit with the proposed change, and review real-user measurements when available.
For CI, separate hard limits from warnings. A hard limit might block a substantial JavaScript increase on a critical route. A warning might flag a small request-count change for review. This prevents teams from ignoring every failure because a strict budget creates noise.
Worked examples
Example 1: A dashboard route
A dashboard has a 170 KB compressed JavaScript budget. The shell and authentication code use 60 KB, the chart package uses 48 KB, and the table feature uses 42 KB. The route totals 150 KB, leaving 20 KB of headroom. A proposed export feature adds 35 KB, producing a 185 KB total. The release review should not simply reject the feature; it should test whether export can be lazy-loaded, whether a smaller chart module is available, or whether the feature belongs behind an explicit user action.
Example 2: An image-led landing page
The page has a 300 KB above-the-fold image budget. The hero image transfers 220 KB, while a logo and two supporting images add 125 KB, for a total of 345 KB. The team can reduce the cost by serving a correctly sized hero, deferring below-the-fold images, reserving image dimensions to protect CLS, and checking whether decorative images need to load before interaction.
Example 3: A metric regression
A build stays within all byte budgets but INP worsens. Investigation shows that hydration now processes a large interactive list immediately after load. The appropriate fix may be to reduce client-side work, split the component, defer nonessential listeners, or render less data initially. This example illustrates why a performance budget should include both resource limits and Core Web Vitals review.
When to recalculate
Revisit the budget whenever the inputs change, not only when a release fails. Recalculate after a framework upgrade, routing change, design-system update, new analytics or consent tooling, image strategy change, authentication redesign, or major API response change. Also review it during a quarterly performance audit and after a sustained field-metric regression.
Standards, browser APIs, audit-tool behavior, and framework recommendations can change. Confirm the current definitions of Core Web Vitals and the configuration supported by your chosen CI tool before copying thresholds into a permanent gate. Keep the date, test configuration, and rationale in the repository.
To operationalize the template, add a budget file per important route, generate a production build in CI, run repeatable synthetic checks, compare results with the base branch, and publish the report with the build artifact. During release review, ask four questions: Which budget changed? Why did it change? Is the user-facing metric affected? What compensating action or follow-up has an owner?
Use the budget as a shared engineering utility rather than a one-time audit. A small, explainable threshold that teams review on every feature is more valuable than an ambitious target that nobody measures.