0%
Frontend System Design Interviews: Components, Rendering, State, Caching and Performance
Frontend Performance
Performance is the deep dive interviewers reach for most often in frontend rounds, because it is where browser knowledge shows. Anyone can say the page should be fast. A strong candidate says which metric they will move, what drives it on this page and which change moves it. This lesson gives you that vocabulary: the Core Web Vitals and their causes, performance budgets, code splitting and bundle analysis, image and font loading, long lists and main thread work, and how to measure in the lab and in the field.
Earlier lessons own some neighbouring material. Rendering strategy choices such as server rendering, streaming and hydration are in the rendering strategies lesson. Re-render cost from state placement is in the state management lesson. Caching and prefetching are in the data fetching lesson. Here they appear only as levers on the metrics.
Why metrics, not adjectives
Fast means different things to different people. A developer on a fibre connection with a new laptop experiences a different page from a user on a three year old Android phone on a train. Metrics make performance a shared, testable requirement. In the requirements step of the framework, a performance budget such as largest contentful paint under two and a half seconds at the 75th percentile on mid range mobile is a requirement just like a feature, as the requirements lesson discussed.
Google's Core Web Vitals are the most widely used set, partly because they affect search ranking and partly because they map well onto what users notice. There are three, covering loading, responsiveness and visual stability.
Largest Contentful Paint
Largest Contentful Paint, or LCP, is the time from the start of navigation until the largest image or text block in the viewport is rendered. On a product page that is usually the hero image; on an article it is often the headline or the first paragraph; on a feed it may be the first post's image. It approximates when the user feels the main content has arrived. A good LCP is 2.5 seconds or less, measured at the 75th percentile of page loads; above 4 seconds is poor.
LCP is useful to break into four parts, because each part has different fixes. Time to first byte is how long the server takes to start sending the HTML. Resource load delay is the gap between the first byte and the moment the browser starts downloading the LCP resource, such as the hero image. Resource load duration is how long that download takes. Element render delay is the time between the download finishing and the element actually painting, often because scripts or styles are still blocking rendering.
In practice, the biggest part on many slow pages is resource load delay: the browser does not know about the hero image until late, because it is set by JavaScript after hydration, loaded through a CSS background image, or marked as lazy loaded. Fixing discovery often cuts LCP by a second with no change to the image itself. Time to first byte improves with server rendering at the edge, caching HTML at the CDN and faster backends. Load duration improves with smaller, modern image formats and a nearby CDN. Render delay improves by reducing render blocking scripts and styles and by not hiding content until a script runs.
Interaction to Next Paint
Interaction to Next Paint, or INP, measures responsiveness. For each click, tap or key press during the visit, the browser measures the time from the input until the next frame is painted. INP reports roughly the worst of these interactions for the visit, ignoring a few outliers on pages with many interactions. A good INP is 200 milliseconds or less at the 75th percentile; above 500 milliseconds is poor. INP replaced the older First Input Delay metric, which only measured the delay before the first interaction's handler started and missed slow handlers and slow rendering.
Each interaction has three parts. Input delay is time the input waits because the main thread is busy with something else, such as a long script or a hydration pass. Processing time is how long the event handlers take. Presentation delay is the time to recalculate styles, lay out and paint the result, which grows with the size of the DOM and the amount of change.
The single biggest driver of poor INP is long tasks on the main thread: any task over 50 milliseconds blocks input for its duration. Heavy hydration on load, large re-renders on each keystroke, synchronous parsing of big JSON payloads, third party scripts and huge DOM trees are the usual culprits. The fixes, covered later in this lesson, are breaking work into smaller pieces, yielding to the browser, moving computation to web workers, reducing re-render scope and shrinking the DOM with virtualization.
Cumulative Layout Shift
Cumulative Layout Shift, or CLS, measures visual stability: how much visible content moves unexpectedly while the user is looking at the page. Each unexpected shift gets a score based on how much of the viewport moved and how far, and CLS reports the largest burst of shifts during the visit. A good CLS is 0.1 or less at the 75th percentile; above 0.25 is poor. Shifts that happen within half a second of a user's input, such as a menu expanding after a click, do not count, because the user caused them.
The classic causes are images and videos without dimensions, which take up no space until they load and then push content down; ads, embeds and banners injected above existing content; web fonts that swap in with different metrics and reflow text; and content that loads late into a slot with no reserved height, such as a recommendations panel or a cookie banner at the top. The fixes are almost always to reserve space: set width and height or an aspect ratio on media, give late loading regions a minimum height matching their expected content, insert new content below the viewport or behind a user action and match fallback font metrics to the web font.
Other metrics worth knowing
The three vitals are not the whole picture. First Contentful Paint marks when anything appears, which matters for perceived progress. Time to First Byte is worth tracking on its own because it bounds everything else. Total Blocking Time is a lab metric that sums the blocking portion of long tasks during load and correlates with INP. For single page apps, also measure route transitions: the time from a click on an in app link to the new screen's main content appearing, because Core Web Vitals mostly measure the first load, and an app that loads fast but navigates slowly still feels slow. Custom marks for your product's key moments, such as time until the feed's first image is visible, are often more meaningful than any standard metric.
How the vitals interact
The three vitals pull against each other more often than people expect. Lazy loading images saves bytes and can help LCP elsewhere on the page, but without reserved space it worsens CLS. Server rendering usually improves LCP but can worsen INP if a large hydration pass blocks the first taps. Inlining critical CSS speeds the first paint but makes the HTML larger and uncacheable. A good design names the trade-off and the mitigation together, for example server render the feed for LCP and hydrate it progressively so early taps on the like button are not blocked.
What the interviewer is checking
When an interviewer asks how you would make the page fast, they are checking whether you name specific metrics, know their thresholds approximately and connect each one to causes on this page. A strong answer sounds like this: for the product page, LCP is the hero image, so I make sure it is in the server rendered HTML with a high fetch priority and explicit dimensions; INP risk is the filter panel, so I keep filter state local and defer the heavy results list; CLS risk is the reviews widget, so I reserve its height. A weak answer lists techniques without saying which metric each one serves.
For every main screen in your design, say what the largest contentful element will be, usually a hero image or headline, and how the browser discovers it. It is the fastest way to show you understand loading performance rather than reciting a checklist.