Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
Frontend System Design Roadmap
  1. 1.HTTP/1.1 vs HTTP/2 vs HTTP/3 (QUIC)
  2. 2.TCP and TLS Handshakes: Connection Setup Costs
  3. 3.Browser Network Stack and Connection Pooling
  4. 4.GET vs POST and Idempotency in HTTP
  5. 5.The Critical Rendering Path (CRP)
  6. 6.DOM, CSSOM and the Render Tree
  7. 7.Layout, Paint and Compositing
  8. 8.Reflows and Repaints Explained
  9. 9.Event Loop: Call Stack, Task and Microtask Queues
  10. 10.Async JavaScript: Promises and async/await
  11. 11.Web Workers: Multi-threading in the Browser
  12. 12.Browser Storage: Cookies, Web Storage, IndexedDB
  13. 13.Client-Side Storage: Limits and Security Risks
  14. 14.Choosing the Right Client-Side Storage
  15. 15.HTTP Caching: Cache-Control, ETag, Last-Modified
  16. 16.Browser-Level Caching Mechanisms
  17. 17.Cache Invalidation for Frontend Apps
  18. 18.Structuring a Large Single-Page App
  19. 19.Component-Based Architecture Principles
  20. 20.Props, State and Component Lifecycle
  21. 21.Module Bundling Basics
  22. 22.Core Web Vitals: LCP, INP and CLS
  23. 23.FCP and Time to Interactive (TTI) Explained
  24. 24.Measuring Performance: Lighthouse and WebPageTest
  25. 25.Asset Compression and Minification Basics
  26. 26.What Is a CDN and How Does It Work?
  27. 27.CDN Benefits: Latency, Availability, Offload
  28. 28.CDN Cache Behavior and Invalidation
  29. 29.Global State vs Local Component State
  30. 30.State Patterns: Redux, Zustand and Context
  31. 31.Data Fetching: React Query and SWR
  32. 32.Immutable Data in Frontend State
  33. 33.SSR vs CSR: Rendering Trade-offs
  34. 34.Hydration and Time to First Byte (TTFB)
  35. 35.Static Site Generation (SSG) for Speed and SEO
  36. 36.Incremental Static Regeneration (ISR)
  37. 37.Micro-Frontends: Core Principles
  38. 38.Micro-Frontend Integration Strategies
  39. 39.Communication Between Micro-Frontends
  40. 40.Micro-Frontends: Pros and Cons for Large Teams
  41. 41.Real-Time: Polling, SSE and WebSockets
  42. 42.Real-Time Use Cases: Chat, Alerts, Live Data
  43. 43.Designing a Real-Time Data Flow
  44. 44.Scaling WebSocket Connections
  45. 45.Responsive Images: srcset, sizes and picture
  46. 46.Modern Image Formats: WebP, AVIF, JPEG XL
  47. 47.Lazy Loading Images and Videos
  48. 48.Video Streaming: HLS, DASH, Adaptive Bitrate
  49. 49.REST and GraphQL for Frontend Engineers
  50. 50.Batching, Throttling and Debouncing API Calls
  51. 51.Handling API Errors in the Frontend
  52. 52.Authentication Flows: OAuth and JWT
  53. 53.Global Error Boundaries in React
  54. 54.Error Reporting: Sentry and LogRocket
  55. 55.Graceful Degradation and Fallback UIs
  56. 56.Real User Monitoring (RUM)
  57. 57.CORS: Cross-Origin Resource Sharing
  58. 58.Preventing XSS (Cross-Site Scripting)
  59. 59.CSRF Protection for Frontend Apps
  60. 60.Content Security Policy (CSP)
  61. 61.Storing Auth Tokens: Cookies vs localStorage
  62. 62.PWA Manifest and Installability
  63. 63.Service Workers: Lifecycle and Caching Strategies
  64. 64.Offline Support and Background Sync
  65. 65.Push Notifications for Web Apps
  66. 66.Webpack vs Vite vs Parcel
  67. 67.Code Splitting, Tree Shaking, Asset Optimization
  68. 68.Module Resolution and Hot Module Replacement
  69. 69.Monorepo Tooling: Nx and Lerna
  70. 70.Atomic Design for Component Libraries
  71. 71.Theming and Customization in Design Systems
  72. 72.Accessibility in Component Libraries
  73. 73.Component Library Docs, Testing and Versioning
  74. 74.Publishing and Consuming a Component Library
  75. 75.Full-Text Search: Levenshtein and Fuzzy Matching
  76. 76.Indexing Large Datasets in the Browser
  77. 77.Search Performance: Debouncing and Web Workers
  78. 78.Integrating Backend Search Services
  79. 79.Choosing a Chart Library: D3, Chart.js, Recharts
  80. 80.Rendering Large Datasets: Canvas vs SVG
  81. 81.Interactive, Responsive Data Visualizations
  82. 82.Data Fetching and Aggregation for Dashboards
  83. 83.A/B Test Design and Rollout Strategies
  84. 84.Client-Side vs Server-Side A/B Testing
  85. 85.Feature Flags and Remote Configuration
  86. 86.Experiment Data Collection and Analytics
Frontend System Design Roadmap
22

Frontend System Design · Lesson 22 of 86 · 4 min

Core Web Vitals: LCP, INP and CLS

You need to explain these three metrics, their causes, and how to fix them—it's a standard performance question.

After this, you'll be able to articulate what each Core Web Vital measures, why it matters for user experience, and the specific technical fixes for common problems. This isn't just theory; it's about demonstrating you can build fast, stable, and responsive UIs.

What LCP actually measures

Largest Contentful Paint (LCP) measures perceived loading speed. It marks the point when the largest image or text block visible in the viewport has rendered. A good LCP reassures the user that the page is useful and loading correctly.

The target is under 2.5 seconds.

The "largest element" can be an <img>, an <image> inside an <svg>, a video's poster image, an element with a background-image, or a block-level element containing text. The browser keeps track of the largest element as the page loads and reports the final one.

The trap: Don't confuse LCP with First Contentful Paint (FCP). FCP is when the first piece of content appears (like a header or a spinner). LCP is when the main content likely appears. An interviewer might ask you to compare them to see if you know the distinction.

A slow LCP is usually caused by one of four things: slow server response times, render-blocking JavaScript and CSS, slow resource load times, or client-side rendering issues.

How to fix a slow LCP

Start by identifying the LCP element using Chrome DevTools (in the Performance tab, look for the LCP marker in the Timings track). Once you know what it is, fix it in this order:

  1. Optimize the element itself. If it's an image, this is your highest-impact fix. Compress it, serve it in a modern format like AVIF or WebP, and use srcset to provide responsive sizes. No 2MB hero image should ever hit production.

  2. Prioritize loading the element. Add <link rel="preload" as="image" href="your-lcp-image.jpg"> to the <head>. This tells the browser to fetch the image with high priority, often in parallel with render-blocking CSS, instead of waiting for the <img> tag to be discovered.

  3. Eliminate render-blocking resources. Audit your scripts and stylesheets in the <head>. Use defer for JavaScript that isn't needed for the initial paint. Split your CSS to inline critical styles needed for above-the-fold content and load the rest asynchronously.

Why INP replaced FID for interactivity

Interaction to Next Paint (INP) measures a page's overall responsiveness to user input. It replaced First Input Delay (FID) because FID only measured the delay of the first interaction. INP is more comprehensive, considering the latency of all interactions throughout the user's visit.

The target is under 200 milliseconds.

INP measures the entire duration from an event (like a click or key press) until the next frame is painted with visual feedback. This includes:

  • Input delay: Time spent waiting for the main thread to become available.
  • Processing time: Time it takes to run the event handlers.
  • Presentation delay: Time it takes the browser to calculate the new frame and paint it.

The interview angle: Explaining why INP is a better metric than FID shows you understand the user experience beyond the initial load. It demonstrates you think about long-lived pages and complex applications, not just simple landing pages. A high INP means your page feels sluggish or "janky."

The primary cause of poor INP is a busy main thread. Long-running JavaScript tasks, large rendering updates, and heavy event handlers all block the browser from responding quickly to user input.

How to stop content from jumping (CLS)

Cumulative Layout Shift (CLS) measures visual stability. It quantifies how much visible content shifts unexpectedly during the page load. A low CLS score means the page layout is stable and predictable.

The target score is 0.1 or less.

The most common cause of CLS is images or ads loading without their dimensions specified. The browser doesn't know how much space to reserve, so when the resource finally loads, it pushes other content down, causing a jarring shift.

The fix is simple: always provide dimensions.

For images and videos, add width and height attributes. The browser uses these to compute an aspect ratio and reserve the correct amount of space before the media loads.

<!-- BAD: Causes layout shift -->
<img src="post-image.jpg" alt="A descriptive alt text.">

<!-- GOOD: Browser reserves space immediately -->
<img src="post-image.jpg" width="800" height="450" alt="A descriptive alt text.">

For responsive images, you still use width and height, but you control the display size with CSS (width: 100%; height: auto;). The browser still knows the intrinsic aspect ratio from the attributes.

A more modern CSS-only approach is the aspect-ratio property. This is great for responsive containers holding images, videos, or embeds.

.image-container {
  width: 100%;
  aspect-ratio: 16 / 9; /* Reserves a 16:9 space */
  background-color: #eee;
}

.image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

Other common causes are dynamically injected ads, embeds, or banners. For these, you must reserve space in the layout ahead of time, usually by setting a min-height on the container they will load into.

Try it

Open DevTools on a media-heavy site like a news homepage. Use the Performance tab to record a page load. Find the LCP element in the Timings track. Then, enable the "Layout Shift Regions" checkbox in the Rendering panel (find it under More Tools), reload, and see if you can spot and debug what causes content to jump.

Next: We'll look at two other important timing metrics in "FCP and Time to Interactive (TTI) Explained".

Lock it in — apply this lesson under interview conditions.

Try a free mock interviewPractice system design problems
Previous

Module Bundling Basics

Next

FCP and Time to Interactive (TTI) Explained