Browser & Web Performance Middle interview questions and answers
75 questions for a Browser & Web Performance (Middle) interview - with correct answers, explanations and links to the docs.
Take this quiz- 1.What problem does this code cause?
- 2.Which CSS properties can usually be animated without triggering layout or paint?
- 3.What is the risk of adding
will-change: transformto many elements? - 4.Why is
requestAnimationFramebetter thansetInterval(fn, 16)for visual updates? - 5.What does
content-visibility: autodo? - 6.Why does a very large DOM (tens of thousands of nodes) hurt responsiveness?
- 7.What does CSS
contain: layout painttell the browser? - 8.Which change usually causes only a repaint, without layout?
- 9.What is the main thread responsible for in a typical browser tab?
- 10.Which three parts make up the latency of a single interaction in INP?
- 11.A click handler does heavy, non-urgent work after updating the UI. How can you make the update appear sooner?
- 12.What is the advantage of
scheduler.yield()oversetTimeout(resolve, 0)for yielding? - 13.When are Web Workers a good fit for improving INP?
- 14.What does Total Blocking Time (TBT) measure in a lab test?
- 15.Which INP value is reported for a page with many interactions?
- 16.A search box filters a 5 000-item list on every keystroke and typing feels laggy. Which fix helps INP the most?
- 17.What does presentation delay in INP mostly depend on?
- 18.What does
requestIdleCallbackdo? - 19.Why can third-party scripts hurt INP even if they load with
async? - 20.LCP can be split into four parts. Which list is correct?
- 21.The LCP image is set as a CSS
background-image. Why does that often hurt LCP? - 22.What does
fetchpriority="high"on the LCP<img>do? - 23.Why can a client-side rendered SPA have a poor LCP even on a fast network?
- 24.What does a
103 Early Hintsresponse let the server do? - 25.What does an image CDN typically do?
- 26.LCP is measured until when?
- 27.Which layout shifts are excluded from CLS?
- 28.How is the CLS value for a page visit computed?
- 29.How can you reduce CLS caused by web fonts?
- 30.A banner is inserted at the top of the page after an API call and pushes content down. What is the best fix?
- 31.Why are animations with
transformbetter than animatingtopfor CLS? - 32.Why must a preloaded font have the
crossoriginattribute? - 33.What does
<link rel="modulepreload">do differently frompreload? - 34.What does code splitting with dynamic
import()give you? - 35.What does tree shaking rely on to remove unused code?
- 36.What is a facade for a heavy third-party embed, like a video player?
- 37.What does the Speculation Rules API allow?
- 38.Why should you avoid preloading too many resources?
- 39.What does
Cache-Control: max-age=60, stale-while-revalidate=600allow? - 40.What is
s-maxageused for? - 41.What is the
Varyresponse header for? - 42.A response has no
Cache-ControlorExpires, but hasLast-Modified. Can the browser cache it? - 43.What does
must-revalidateadd to a cached response? - 44.Which service worker caching strategy fits hashed static assets best?
- 45.Which strategy fits an API response that should be fresh but must also work offline?
- 46.What is the Cache Storage API (
caches.open) compared to the HTTP cache? - 47.Which cross-origin request is sent without a preflight?
- 48.The frontend sends
fetch(url, { credentials: "include" })to another origin. What must the response contain? - 49.Your JS can't read a custom
X-Total-Countheader from a cross-origin response. Why? - 50.What does
Access-Control-Max-Agedo? - 51.A server reflects the request's
OriginintoAccess-Control-Allow-Originfor an allowlist of sites. Which header should it also send? - 52.Does a CORS error mean the request never reached the server?
- 53.What is an opaque response?
- 54.What is CSRF?
- 55.What is clickjacking and which header defends against it?
- 56.What does
X-Content-Type-Options: nosniffdo? - 57.What does the
integrityattribute (Subresource Integrity) protect against? - 58.Why is
<a href={userUrl}>dangerous ifuserUrlisn't validated? - 59.What must a
messageevent handler check before trustingevent.data? - 60.Why does CSP with
'unsafe-inline'inscript-srcprovide little XSS protection? - 61.How does a nonce-based CSP decide which inline scripts may run?
- 62.What does
Referrer-Policy: strict-origin-when-cross-origin(the browser default) send? - 63.What is the difference between same-site and same-origin?
- 64.What is the back/forward cache (bfcache)?
- 65.How can a page detect that it was restored from bfcache?
- 66.What is the most reliable moment to send analytics before the user leaves?
- 67.How can you mark custom points in time to see them in DevTools and measure them in code?
- 68.How do you collect LCP, INP and CLS from real users with little code?
- 69.What is CrUX (Chrome UX Report)?
- 70.What is the
Server-Timingheader useful for? - 71.Why does Resource Timing show zeros for DNS, connect and request phases of some cross-origin resources?
- 72.What problem of HTTP/2 over TCP does HTTP/3 solve?
- 73.What does the
Clear-Site-Dataheader do, for example on logout? - 74.What does
Permissions-Policy: camera=(), geolocation=(self)do? - 75.Why does a third-party cookie set inside an embedded iframe often not work anymore?