Web Performance Interview Questions

20 Web Performance interview questions with worked answers, complexity notes, and runnable code you can edit in the browser — ordered easy to hard so you build up steadily. Free, no signup. Open any question for the full answer.

Measure first, then spend the main thread wisely

Performance work goes wrong the same way every time: someone optimizes what is easy to optimize instead of what is slow. So the first move, always, is to measure — and to know which measurement you are looking at. Lab data (Lighthouse, a profiler on your machine) is reproducible and good for diagnosis; field data (real users, the Core Web Vitals your users actually experience) is the truth you are ultimately judged on. They disagree constantly, and understanding why is half the skill.

The Core Web Vitals give you a shared vocabulary. LCP measures how fast the main content paints, and you improve it by attacking its sub-parts — time to first byte, resource load time, render delay — not by guessing. INP measures responsiveness, and it comes down to long tasks: any script that hogs the main thread for tens of milliseconds is what makes a tap feel stuck, so you break work up, defer it, or move it to a Web Worker. CLS measures visual stability, and you fix it at the source by reserving space for images, ads, and late-arriving content so nothing jumps.

Underneath the metrics sits the critical rendering path: render-blocking CSS and JavaScript decide how fast anything appears at all, which is why code-splitting, deferring non-critical scripts, and trimming the bundle matter so much. Every kilobyte of JavaScript is paid for twice — once to download and again to parse and execute — so the cheapest fast code is the code you never ship. The questions here move from these foundations through the working techniques (virtualization, lazy loading, IntersectionObserver, resource hints used as a scalpel) into hunting the memory leaks and layout thrash that only show up under real use.

Easy

Medium

Hard

Other topics

HTML/CSS · Browser · JavaScript · TypeScript · React · System Design · Accessibility · Testing · Networking/Security · DSA

← Search all 265 questions