Okay, the user wants a browser performance budget with specific gates (LCP/CLS/INP), code splitting, priority hints, and alerts. Let me break down each component.
First, the Core Web Vitals gates are straightforward—need to set thresholds for LCP, CLS, and INP based on industry standards. Maybe reference the "good" thresholds from Google. Should also include some buffer for real-world variability.
Code splitting is about chunk sizing and loading strategies. Need to define max chunk sizes and maybe dynamic import rules. Priority hints are for fonts and critical resources—must specify preload and early hints. Alerts should tie into monitoring tools, maybe via CI/CD or RUM.
Wait, the user mentioned "alerts" but didn't specify the tool. Should suggest common ones like Lighthouse CI or SpeedCurve. Also, need to clarify enforcement—maybe automated gates in PRs and CI pipelines.
Including a table format would make it clear. Need to balance strictness with practicality. For example, LCP might be set at 2.2s instead of 2.5s to account for network variations. Also, code splitting max chunk at 100KB gzipped seems reasonable. Priority hints for fonts and hero images.
Should emphasize that this is a starting point and needs team buy-in. Maybe add a checklist for implementation steps. Let me structure: thresholds table, code split rules, priority hints, alert setup, and enforcement mechanisms. Keep it concise but actionable.
Here’s a production-ready browser performance budget designed to enforce key user experience metrics, optimizations, and automated guarding. It’s structured for clarity, enforcement, and team alignment.
🎯 Browser Performance Budget
Version: 1.0 • Enforcement: CI/CD, PR gates, RUM alerts
1. Core Web Vitals Gates (Non-Negotiable)
These are fail criteria—if a pull request causes regression beyond these thresholds, it blocks merge.
Metric
Good Threshold (Target)
Budget Gate (Max Allowed)
Measurement Tool
LCP (Largest Contentful Paint)
≤ 2.4s
≤ 2.7s
Lighthouse, Web Vitals RUM
CLS (Cumulative Layout Shift)
≤ 0.1
≤ 0.15
Lighthouse, Web Vitals RUM
INP (Interaction to Next Paint)
≤ 200ms
≤ 250ms
Lighthouse, Web Vitals RUM
Notes:
LCP Gate: Measured on mobile emulation (3G, 4x CPU slowdown) in CI. Real-user monitoring (RUM) alerts if 75th percentile exceeds target.
CLS Gate: Must be 0 for pages with no user interaction before load (e.g., login pages). Otherwise ≤ 0.1.
INP Gate: Critical for interactive pages (dashboards, checkouts). Static sites can relax to ≤ 300ms.
2. Code Splitting & Asset Size Budgets
Prevent monolithic bundles and unnecessary payload.
Asset Type
Budget Limit (Gzipped)
Enforcement
Main JS bundle
≤ 150 KB
CI (Webpack Bundle Analyzer, source-map-explorer)
Largest chunk (dynamic import)
≤ 100 KB
CI (same tooling)
CSS (critical + lazy)
≤ 50 KB (critical) + ≤ 30 KB per lazy chunk
CI (CSS Stats)
Fonts
≤ 50 KB total (WOFF2)
Manual review + CI (file size check)
Images
≤ 150 KB per hero image
CI (sharp/image-size) + RUM alert if > 100 KB
Rules:
No synchronous import() for non-critical components—must be lazy-loaded via React.lazy(), import(), or route-based splitting.
Fonts must use font-display: swap and be preloaded only if critical.
Third-party scripts (analytics, chat widgets) must be asynchronous and deferred (async/defer).
3. Resource Loading Priority Hints
Ensure critical resources aren’t blocked by non-critical ones.
Resource
Hint Required
Where to Apply
Critical CSS
Inline <style> in <head>
Above-the-fold styles only
Web Fonts
<link rel="preload" as="font" crossorigin>
For fonts used in first paint
Hero Image/Video
<link rel="preload" as="image"> or fetchpriority="high"
LCP element
Main JS (if non-critical)
type="module" + async
For non-render-blocking logic
Non-critical JS/CSS
rel="prefetch" or rel="preload" (low priority)
Chunks for next navigation
Forbidden:
@import in CSS.
Render-blocking scripts in <head> without async/defer.
Loading non-critical fonts without display: swap or preload.
4. Alerting & Monitoring
Automated alerts when real-user data exceeds targets.
Alert Type
Threshold
Tooling
Action
RUM 75th percentile
LCP > 2.5s OR CLS > 0.1 OR INP > 200ms
Google Search Console, SpeedCurve, New Relic
Page owner notified within 1h
CI/CD Pipeline Failure
Any budget gate failed
Lighthouse CI, Bundlesize, Custom script
PR blocked, comment added
Bundle size increase
> 5% growth in any chunk
GitHub Actions, Bundlewatch
PR comment warning
CLS anomaly
Single-page session CLS > 0.25
RUM tool with session replay flag
Investigate layout shift source
Alert Channels:
Slack/Discord #web-performance channel.
Jira ticket auto-created for owner (based on package.jsonmaintainers field).
Weekly digest of all budget violations.
5. Enforcement & Process
CI/CD Pipeline Checks (run on every PR):
Lighthouse CI (mobile emulation) for Core Web Vitals.
Bundle analysis for size budgets.
Image/font size validation.
Fail if any budget gate exceeded.
Pull Request Template (require checklist):
code
- [ ] Performance budget verified (see CI checks)
- [ ] Code splitting applied for new non-critical components
- [ ] Resource priority hints added for new critical assets
- [ ] No new synchronous third-party scripts
Quarterly Budget Review:
Adjust thresholds based on industry shifts.
Audit third-party script load impact.
Re-evaluate code split strategy (e.g., per-route vs. component-level).
Hero Image Protocol:
All hero images must be in AVIF/WebP with JPEG fallback.
Max dimensions: 2000px wide, compressed to ≤ 100 KB.
Must include width/height attributes to avoid CLS.
✅ Quick Implementation Checklist
Integrate Lighthouse CI into PR checks (mobile, 3G throttling).
Add bundlesize/bundlewatch to package.json and CI.
Set up RUM alerts (Search Console + secondary tool like SpeedCurve).
Document priority hints in frontend guidelines.
Train team on interpreting bundle analyzer reports.
Add performance budget badge to README (e.g., via Shields.io).
Schedule biannual lab testing (WebPageTest, Lighthouse) on key user journeys.
Remember: The budget is a baseline—more aggressive targets (e.g., LCP ≤ 2.0s) may be needed for competitive/global markets. Align with business goals, not just industry “good” scores. Last updated: [DATE] • Owner: [PERF LEAD/FRONTEND ARCHITECT]
This draft provides a balanced, enforceable, and measurable framework. Adjust thresholds based on your site’s current performance—start conservatively, then tighten over time.