Web Performance Interview Questions and Answers
Last updated 2026-11-19
Performance questions test whether you can measure before you optimise and whether you understand where the time goes between a click and a rendered page: DNS, connection, server time, download, parse, layout, paint and JavaScript execution. Strong answers name a metric, a tool and a specific fix, not a list of generic tips.
This page covers the Core Web Vitals, the critical rendering path, caching, images and fonts, JavaScript cost and the tools used to measure them. It builds on the frontend developer questions and HTML and CSS questions, and the practical side is covered for React apps in the React interview questions.
| Core metrics | LCP, INP, CLS, plus TTFB and FCP |
|---|---|
| Tools | Lighthouse, Chrome DevTools, WebPageTest, CrUX, web-vitals library |
| Questions here | 17 |
Lab data versus field data
Lighthouse and DevTools give lab data: a controlled run on one device and network, good for debugging. Field data comes from real users, collected through the Chrome User Experience Report or your own use of the web-vitals library, and it is what Google uses for page experience. A page can score well in the lab and fail in the field, because real users have slower devices, cold caches and long interactions the lab script never performs.
Thresholds to remember
- Largest Contentful Paint: good at 2.5 seconds or less.
- Interaction to Next Paint: good at 200 milliseconds or less. It replaced First Input Delay as a Core Web Vital in March 2024.
- Cumulative Layout Shift: good at 0.1 or less.
- These are assessed at the 75th percentile of page loads, separately for mobile and desktop.
Web Performance Interview Questions and Answers: questions with worked answers
1 What are the Core Web Vitals?
easyThree user-centred metrics: Largest Contentful Paint for loading, Interaction to Next Paint for responsiveness and Cumulative Layout Shift for visual stability. Good values are 2.5 seconds or less, 200 milliseconds or less and 0.1 or less, measured at the 75th percentile of real user visits. INP replaced First Input Delay in 2024 because it observes all interactions over the page visit, not only the first.
2 What is the critical rendering path?
easyIt is the sequence the browser follows to show pixels: parse HTML into the DOM, parse CSS into the CSSOM, combine them into a render tree, compute layout, paint and composite. CSS blocks rendering, and synchronous scripts block HTML parsing. To speed it up, ship less critical CSS, defer scripts, and avoid chains of dependent requests that delay the first paint.
3 How do you improve Largest Contentful Paint?
mediumFirst find the LCP element, usually a hero image or heading block, and which of four parts is slow: time to first byte, resource load delay, resource load time or render delay. Reduce server time with caching and a CDN, make the image discoverable in the HTML rather than loaded by JavaScript, add fetchpriority="high" and never lazy-load it, serve it at the right size in AVIF or WebP, and remove render-blocking CSS and scripts.
html<link rel="preload" as="image" href="/hero-1200.avif" fetchpriority="high"> <img src="/hero-1200.avif" width="1200" height="600" fetchpriority="high" alt="Product dashboard">4 How do you fix Cumulative Layout Shift?
mediumReserve space for everything that loads late. Set width and height attributes or CSS aspect-ratio on images, videos and iframes, reserve a fixed slot for ads and embeds, avoid inserting content above existing content, and load web fonts with font-display and matching fallback metrics so text does not jump. Animate with transform instead of properties that move layout. Shifts within 500 ms of a user input are not counted.
cssimg, video { max-width: 100%; height: auto; } .hero { aspect-ratio: 16 / 9; } @font-face { font-family: Brand; src: url(brand.woff2) format('woff2'); font-display: swap; }5 What is INP and how do you improve it?
mediumInteraction to Next Paint measures the latency from a user input, such as a click or key press, until the browser paints the next frame, reporting roughly the worst interaction. Delay comes from the main thread being busy. Break long tasks into chunks under 50 ms, yield to the main thread, move heavy work to a web worker, reduce JavaScript and avoid expensive layout work in event handlers. Show immediate visual feedback and defer non-urgent work.
javascriptasync function processAll(items) { let last = performance.now(); for (const item of items) { handle(item); if (performance.now() - last > 40) { await new Promise((r) => setTimeout(r, 0)); // yield so input can be handled last = performance.now(); } } }6 Explain HTTP caching headers.
mediumCache-Control directs caching: max-age sets freshness in seconds, no-store forbids storing, no-cache means revalidate before use, and immutable tells the browser the file never changes. ETag and Last-Modified allow conditional requests answered with 304 Not Modified. The best practice is fingerprinted file names such as app.3f9a1c.js with a one-year immutable cache, while HTML is served with no-cache or a short max-age so users get new file names promptly.
textCache-Control: public, max-age=31536000, immutable # app.3f9a1c.js Cache-Control: no-cache # index.html (revalidate)7 What do preload, prefetch, preconnect and dns-prefetch do?
mediumpreload fetches a resource needed for the current page at high priority, such as a font or hero image the parser cannot discover early. prefetch fetches a resource likely needed on a later navigation at low priority. preconnect opens a connection, DNS, TCP and TLS, to an origin you will use soon. dns-prefetch does only the DNS lookup. Overusing preload competes with critical resources and slows the page.
8 How do you optimise images?
mediumServe modern formats such as AVIF or WebP with a fallback, resize to the displayed dimensions and use srcset with sizes so devices get the right file, compress sensibly, lazy load images below the fold with loading="lazy" but not the LCP image, set dimensions to avoid layout shift, and serve from a CDN with long caching. Use SVG for icons and logos, and video elements rather than animated GIFs.
9 How do you reduce the cost of JavaScript?
mediumJavaScript costs download, parse, compile and execute time, and execution blocks the main thread. Measure bundles, split code by route with dynamic import, remove unused dependencies and code through tree shaking, defer non-critical scripts, load third-party scripts lazily or in a worker, and ship modern syntax to modern browsers. On a slow phone, 300 KB of compressed JavaScript can take seconds to run.
10 async versus defer, and why do third-party scripts hurt?
mediumBoth download without blocking the parser. async executes as soon as ready, in any order. defer executes after parsing, in order. Third-party tags such as analytics, chat and ads add network requests, main-thread work and layout shifts outside your control. Load them after interaction or idle time, use facades for heavy embeds such as video players, and audit them regularly in the performance trace.
11 What does a CDN do and what should it cache?
mediumA CDN serves content from a server near the user, cutting latency, and absorbs load from your origin. Cache static assets for a long time, and consider caching HTML for anonymous users with short lifetimes or stale-while-revalidate. Use compression, such as Brotli for text, HTTP/2 or HTTP/3 and TLS termination at the edge. Be careful not to cache personalised responses, and vary on the right headers.
12 How does HTTP/2 and HTTP/3 change performance advice?
hardHTTP/2 multiplexes many requests over one connection, so the old habits of domain sharding and concatenating everything into one file matter less, though very many tiny files still have overhead. HTTP/3 runs over QUIC on UDP, which removes head-of-line blocking at the transport layer, speeds up connection setup and survives network changes. Server push was removed from Chrome, with 103 Early Hints as the replacement for sending preload hints early.
13 How do you measure and monitor performance properly?
hardUse lab tools such as Lighthouse and the DevTools Performance panel to diagnose, and field data from CrUX or the web-vitals library to see what users experience, tracked at the 75th percentile and segmented by device and page. Set performance budgets for bundle size and metrics, and run checks in CI, so regressions are caught before release. Alert on field metric changes after deploys.
javascriptimport { onLCP, onINP, onCLS } from 'web-vitals'; function send(metric) { navigator.sendBeacon('/analytics', JSON.stringify({ name: metric.name, value: metric.value, id: metric.id })); } onLCP(send); onINP(send); onCLS(send);14 What are the trade-offs between SSR, SSG and CSR for performance?
hardClient-side rendering ships a small HTML shell and renders after JavaScript runs, so LCP is late and relies on device speed. Server-side rendering sends complete HTML so content appears sooner, but time to first byte rises and hydration costs main-thread time, which can hurt INP. Static generation serves pre-built HTML from a CDN and is fastest, but suits content that changes rarely. Streaming and partial hydration reduce the cost, and Server Components cut JavaScript sent.
15 What is the back/forward cache and how can you keep a page eligible?
hardThe back/forward cache keeps a complete page snapshot in memory so back and forward navigation is instant. Pages become ineligible through unload handlers, Cache-Control: no-store on the main document in many cases, open connections such as WebSockets that are not closed, and some APIs. Use the pageshow and pagehide events instead of unload, and check eligibility in the DevTools Application panel.
16 How do you find what makes a page slow, step by step?
hardRun Lighthouse for a first view, then record a DevTools Performance trace with CPU and network throttling on a mobile profile. Look at the network waterfall for late or blocking requests, the main thread flame chart for long tasks, and the Layout Shifts and LCP markers. Identify the cause, change one thing, and re-measure. Confirm with field data after release, because lab improvements do not always reach users.
17 How do you keep a long list or heavy dashboard responsive?
hardRender only what is visible with virtualisation, paginate or load incrementally from the server, and avoid layout work in scroll handlers by using passive listeners and IntersectionObserver. Use content-visibility: auto to skip rendering off-screen sections, debounce expensive handlers, memoise computations and move parsing or aggregation to a web worker. Measure with the Performance panel, not by intuition.
css.section { content-visibility: auto; contain-intrinsic-size: auto 600px; }
Frequently asked questions
What is the most important web performance metric?
There is no single one. The Core Web Vitals, LCP, INP and CLS, are the standard set, measured on real users at the 75th percentile.
Why is my Lighthouse score good but users report slowness?
Lab runs use a fixed device and network. Real users have slower phones, cold caches and complex interactions, so check field data in CrUX or your own monitoring.
Does performance affect SEO?
Core Web Vitals are part of Google page experience signals, though content relevance matters far more. Poor performance mostly hurts conversion and engagement.
Is lazy loading always good?
No. Lazy load below-the-fold images and components, but never the LCP image, since it delays the most important content.
Related guides
- Frontend Developer Interview Questions and Answers
- HTML and CSS Interview Questions and Answers
- React Interview Questions and Answers (React 19)
- Next.js Interview Questions and Answers (Next.js 15)
- Web Security and OWASP Interview Questions and Answers
- Full Stack Developer Interview Questions and Answers
More in Role-wise Interview Questions by Job and Tech Stack
- Web Security and OWASP Interview Questions and Answers
- A/B Testing Interview Questions and Answers
- Android Developer Interview Questions and Answers
- Angular Interview Questions and Answers (Angular 18 and Later)
- Ansible Interview Questions and Answers
- API Testing and Postman Interview Questions
- Automation Testing Interview Questions and Answers
- AWS Interview Questions and Answers
- Azure Interview Questions and Answers
- Backend Developer Interview Questions and Answers
- Business Analyst Interview Questions and Answers
- Cloud Engineer Interview Questions and Answers