Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
Web Performance & Core Web Vitals
  1. 1.Introduction to Web Performance & Business Impact
  2. 2.Core Web Vitals & Practical Measurement Tools
  3. 3.Optimizing the Critical Rendering Path & Basic Asset Delivery
  4. 4.JavaScript Performance & Bundle Optimization
  5. 5.Image, Video, and Media Optimization Strategies
  6. 6.Network Performance: HTTP/2, Caching, and CDNs
  7. 7.Resource Hints & Advanced Loading Strategies
  8. 8.Frontend Architectures & Server-Side Rendering Performance
  9. 9.Performance Budgets, RUM, and Continuous Monitoring
  10. 10.Advanced Browser APIs & Offloading Work with Workers
Web Performance & Core Web Vitals
09

Web Fundamentals · Lesson 9 of 10 · 4 min

Performance Budgets, RUM, and Continuous Monitoring

This is how you move from "I made it fast" to "I keep it fast"—a key distinction for senior roles.

After this lesson, you'll be able to explain how to implement and maintain performance at scale. This isn't about one-off fixes; it's about the systems that prevent performance from degrading over time.

Set Performance Budgets to Prevent Regressions

A performance budget is a set of limits on metrics that your site must stay within. Its primary purpose is to act as an automated guardrail in your CI/CD pipeline, preventing performance regressions from ever reaching production.

Think beyond just bundle size. A robust budget strategy includes:

  • Quantity-based budgets: Max number of HTTP requests, image counts, or font files.
  • Size-based budgets: Max JavaScript/CSS size (e.g., < 250KB gzipped), total page weight.
  • Metric-based budgets: Core Web Vitals (LCP < 2.5s), Lighthouse performance score (> 90).

You enforce these with tools like Lighthouse CI or Webpack's performance hints. If a pull request adds a heavy library that pushes the JS bundle size over its budget, the build fails. The developer gets immediate feedback before the code is even merged.

In an interview, describing this CI/CD feedback loop is critical. Don't just say "we should have a budget." Explain how you would automatically enforce it to fail a build. This demonstrates an understanding of process, not just theory.

The trap: Setting an arbitrary, aggressive budget from day one. If your current LCP is 4s, a budget of 2.5s will just cause every build to fail. Start by setting budgets just above your current baseline metrics. This immediately prevents backsliding. Then, you can incrementally tighten the budgets as you make improvements.

This flow shows how budgets integrate directly into your deployment pipeline.

Use RUM to Measure Real User Experiences

Synthetic testing (like Lighthouse in CI) is a controlled lab test. It's essential for catching regressions against a consistent baseline. Real User Monitoring (RUM) is the "field data." It measures performance directly from your users' browsers.

You need both. Synthetic tests tell you if your code got slower. RUM tells you if your users' experience got slower.

RUM answers questions that synthetic tests cannot:

  • How does the site perform for users on slow 3G in a specific country?
  • Did that last deployment improve LCP for users on low-end Android devices?
  • Is a specific third-party script causing high INP for a segment of users?

To implement RUM, you use a library like web-vitals to collect metrics and send them to an analytics service. The key is to send rich context along with the metric: user's device type, effective connection type, country, and the specific page they are on. Without context, the data is just noise.

// src/monitoring.ts
import { getCLS, getLCP, getINP, onCLS, onLCP, onINP } from 'web-vitals';

function sendToAnalytics(metric) {
  // Add context to the metric. This is the most important part.
  const body = {
    event: 'web_vitals',
    name: metric.name,
    value: metric.value,
    path: window.location.pathname,
    // effectiveType is a good proxy for network speed
    connection: (navigator as any).connection?.effectiveType || 'unknown',
  };

  // Use `navigator.sendBeacon` or fetch with `keepalive`
  // to ensure the data is sent even if the user navigates away.
  const url = '/api/performance-metrics';
  if (navigator.sendBeacon) {
    navigator.sendBeacon(url, JSON.stringify(body));
  } else {
    fetch(url, { body: JSON.stringify(body), method: 'POST', keepalive: true });
  }
}

// The `onCLS`, `onLCP`, and `onINP` functions report metrics
// as they are discovered.
onCLS(sendToAnalytics);
onLCP(sendToAnalytics);
onINP(sendToAnalytics);

The trap: Collecting data but never acting on it. RUM is useless if it's just a dashboard nobody looks at. The data must drive action. Set up automated alerts for when your p75 LCP degrades by more than 10% week-over-week. Integrate performance metric reviews into your team's regular sprint planning.

Establish a Continuous Monitoring Feedback Loop

Budgets and RUM are not separate tools; they are two parts of a single feedback loop that constitutes a mature performance culture.

Here is the complete workflow:

  1. Prevent: A developer opens a PR. The automated Lighthouse CI job runs and fails because the new feature increased the main JS bundle size by 100KB, exceeding the 250KB budget. The PR is blocked.
  2. Monitor: A different deployment goes out. RUM data starts showing that p75 LCP has increased by 400ms, but only for users on mobile devices. Synthetic tests didn't catch this because they run on a powerful machine with a fast connection.
  3. Alert: An automated alert fires, notifying the on-call engineer of the LCP regression for mobile users.
  4. Diagnose: The team uses the RUM data to identify the pages and user segments affected. They reproduce the issue locally using Chrome DevTools to throttle CPU and network, confirming the problem.
  5. Fix & Verify: A fix is implemented. The developer verifies it locally and pushes a new PR. The CI budget checks pass. After deployment, the team monitors the RUM dashboard to confirm that p75 LCP for mobile users has returned to normal.

This loop connects development, deployment, and real-world observation. Being able to describe this process clearly signals that you can lead performance efforts on a team, not just fix isolated problems.

Try it

Add the web-vitals library to a small personal project. In your main JavaScript file, import onLCP, onCLS, and onINP. Use them to log the metric values to the console. Open your site and then use Chrome DevTools' "Performance" and "Network" tabs to throttle your CPU (e.g., "4x slowdown") and network (e.g., "Slow 3G"). Reload the page and observe how the reported values change.

Next: We'll look at advanced browser APIs for offloading work from the main thread in Advanced Browser APIs & Offloading Work with Workers.

Lock it in — apply this lesson under interview conditions.

Try an AI mock interview
Previous

Frontend Architectures & Server-Side Rendering Performance

Next

Advanced Browser APIs & Offloading Work with Workers