Browser & Web Performance Senior cheat sheet: interview answers
Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.
1. What does Site Isolation in Chromium guarantee?
Correct answer: Pages from different sites are rendered in different OS processes
After Spectre, process boundaries became the main defense against one site reading another's memory, including cross-site iframes.
2. Why did browsers disable
SharedArrayBufferby default and then re-enable it only for cross-origin isolated pages?Correct answer: It enables high-resolution timers for Spectre attacks
With COOP and COEP the page can't pull in cross-origin resources that haven't opted in, so a Spectre gadget has nothing secret to read.
3. Which pair of headers makes a page cross-origin isolated (
self.crossOriginIsolated === true)?Cross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corpCorrect answer: COOP
same-originplus COEPrequire-corp(orcredentialless)COOP severs the window relationship with cross-origin popups; COEP requires every subresource to opt in via CORS or CORP.
4. After enabling
COEP: require-corp, third-party images stopped loading. What are the options?Correct answer:
CORP: cross-origin, CORS orcredentiallesscredentiallessloads no-cors cross-origin resources without cookies, so they can't contain user-specific secrets.5. What does
Cross-Origin-Opener-Policy: same-originprotect against, besides enabling isolation?Correct answer: Cross-origin windows keeping a
window.openerlinkPopups put in a separate browsing context group can't count your frames, navigate you or measure timings via the window handle.
6. What is
Cross-Origin-Resource-Policy: same-sitefor?Correct answer: Stops other sites from loading it with no-cors requests
CORP protects resources from being pulled into an attacker's process, where speculative execution could leak them.
7. What are Fetch Metadata request headers like
Sec-Fetch-Siteuseful for on the server?Correct answer: Rejecting unexpected cross-site requests early
A resource isolation policy that allows
same-origin,same-siteandnoneplus navigations blocks many CSRF and XS-Leak attempts.8. What are XS-Leaks?
Correct answer: Side channels that infer data about another site
Defenses include COOP, CORP, SameSite cookies, Fetch Metadata checks and avoiding observable differences in responses.
9. Why can a
transformanimation stay smooth even when the main thread is blocked by a long task?Correct answer: The compositor moves a rasterized layer by itself
This works only for compositor-only properties on promoted layers. Animations that need layout or paint stall with the main thread.
10. What is the frame budget for 60 Hz rendering and why is it lower than 16.7 ms in practice?
Correct answer: About 16.7 ms, but JS gets roughly 10 ms of it
On 120 Hz screens the budget is about 8 ms. Work beyond the budget means dropped frames and janky scrolling or animation.
11. Why can a single class change on
<body>be expensive in a large app?Correct answer: It can invalidate styles for the whole subtree
Style recalculation cost depends on how many elements are affected and how complex the selectors matching them are.
12. What does 'layer explosion' refer to?
Correct answer: Too many compositor layers wasting memory
An element above a promoted layer may need its own layer too, so layers can multiply. DevTools Layers panel helps find them.
13. What does
content-visibility: hiddendo differently fromdisplay: none?Correct answer: It skips rendering but keeps the rendering state
Useful for inactive tabs or virtualized views that will be shown again;
display: nonethrows away layout boxes.14. In what case can
content-visibility: automake CLS or scrolling worse?Correct answer: Without
contain-intrinsic-size, sections have no heightUse
contain-intrinsic-size: auto 500pxso the browser remembers the last rendered size of each section.15. What does 'paint holding' in Chromium do for same-origin navigations?
Correct answer: Keeps showing the old page until the new one has content
It improves perceived smoothness. It's one reason fast same-origin navigations can feel almost like an SPA.
16. What does the Long Animation Frames (LoAF) API add over the Long Tasks API?
Correct answer: It reports slow frames with script attribution
Long Tasks only told you that something was slow. LoAF explains why, including rendering time and forced layouts.
17. Why can hydration hurt INP on server-rendered pages?
Correct answer: Long hydration tasks delay the first clicks
Partial or progressive hydration, islands and smaller JS bundles shorten that window.
18. What does
scheduler.postTask(fn, { priority: "background" })let you do?Correct answer: Schedule work with an explicit priority
Priorities are
user-blocking,user-visibleandbackground. Tasks can also be aborted with aTaskController.19. INP is poor, but every event handler takes under 20 ms. What should you look at?
Correct answer: Input delay and rendering after the handler
Timers, third-party scripts or hydration can occupy the main thread when the user clicks; huge DOM updates make the next frame slow.
20. Why is lab INP debugging often misleading compared to the field?
Correct answer: Developers use faster machines than real users
Collect attribution in the field (element, interaction type, LoAF scripts) and reproduce with CPU throttling.
21. How can garbage collection affect INP?
Correct answer: Short-lived objects cause GC pauses on the main thread
Modern GCs are mostly concurrent, but allocation-heavy handlers still cause pauses. The Memory and Performance panels show them.
22. Why are rendering updates in
requestAnimationFramesometimes a hidden source of poor INP?Correct answer: Heavy work there adds directly to presentation delay
Moving expensive work into rAF doesn't remove it from the critical path of the frame that shows the interaction's result.
23. Why are Core Web Vitals assessed at the 75th percentile?
Correct answer: It reflects most users, without extreme outliers
A page passes when the 75th percentile of each metric is in the 'good' range, separately for mobile and desktop.
24. Your RUM shows LCP p75 got worse, but Lighthouse scores are unchanged. What's a likely reason?
Correct answer: The real user mix or field conditions changed
Segment RUM by device class, connection, page type and cache state. A new marketing campaign can shift the mix without code changes.
25. How should performance budgets be enforced in CI for reliable results?
Correct answer: Hard limits on stable metrics, medians for timings
Timing metrics are noisy on shared CI machines. Byte budgets catch most regressions deterministically.
26. What's the benefit of sending LCP attribution (element, sub-parts) along with the value?
Correct answer: You learn which sub-part and element cause slowness
A single number tells you there's a problem; attribution tells you which fix to make.
27. What effect does bfcache eligibility have on field metrics?
Correct answer: Near-instant restores can improve LCP in RUM
Back/forward navigations are a significant share of page views. CrUX counts bfcache restores as navigations.
28. Which header has historically prevented a page from entering bfcache in Chrome?
Correct answer:
Cache-Control: no-storeon the documentBrowsers were cautious about restoring pages marked as not storable. Chrome is gradually relaxing this when no sensitive state changed.
29. How should a page react when it is being prerendered via Speculation Rules?
Correct answer: Delay analytics and side effects until activation
Otherwise page views are counted for pages the user never saw. Many analytics tools already handle this.
30. What's a trade-off of inlining critical CSS in the HTML?
Correct answer: Faster first render, but no separate caching
It's worth it for small critical CSS on entry pages; large inline styles inflate every page load.
31. How does streaming HTML from the server help LCP?
Correct answer: The browser handles early markup while the rest is built
Sending
<head>with CSS and preload hints first lets downloads start in parallel with slow data fetching on the server.32. With HTTP/2 or HTTP/3, why might bundling everything into one JS file still not be ideal?
Correct answer: Any change invalidates the whole bundle in cache
Multiplexing reduces the cost of many requests, so finer-grained chunks give better caching. Too many tiny files still have overhead.
33. What is the main pitfall of a cache key that includes unnecessary request data, like all cookies?
Correct answer: The hit rate drops, as almost every user gets an entry
Keep cache keys minimal and strip tracking query params. Personalize at the edge or on the client instead of fragmenting the cache.
34. What is web cache poisoning?
Correct answer: A shared cache is made to store a harmful response
For example, the app builds URLs from
X-Forwarded-Hostbut the CDN doesn't include that header in the cache key.35. Why might
ETags generated from inode or modification time cause poor cache revalidation behind a load balancer?Correct answer: Servers produce different ETags for the same file
Content-hash ETags are consistent across servers. Weak ETags (
W/) may also be required when compression changes the bytes.36. What problem do targeted headers like
CDN-Cache-Controlsolve?Correct answer: They set CDN caching apart from the browser's
For example, cache HTML at the edge for minutes (purged on deploy) while browsers always revalidate it.
37. What does
Cache-Control: immutablechange?Correct answer: No revalidation of a fresh copy, even on reload
Without it, reloading a page could trigger conditional requests for every asset. It fits only content-hashed URLs.
38. Why is caching an authenticated API response in a shared CDN cache dangerous even with a short TTL?
Correct answer: Another user may get the first user's personal data
Personalized responses need
privateorno-store. Many incidents came from a CDN rule that ignoredAuthorizationor cookies.39. What's wrong with this CORS check?
const origin = req.headers.origin; if (origin && origin.endsWith("example.com")) { res.setHeader("Access-Control-Allow-Origin", origin); res.setHeader("Access-Control-Allow-Credentials", "true"); }Correct answer:
https://evilexample.comalso passes the checkCompare against an exact allowlist of full origins (scheme + host + port). Suffix and regex checks are a classic CORS bug.
40. Why is allowing
Origin: nullin CORS risky?Correct answer: An attacker can easily produce that value
Whitelisting
nullwith credentials effectively allows any attacker page using a sandboxed iframe.41. Does a correct CORS configuration protect an API from CSRF?
Correct answer: No: CORS controls reading, CSRF is about sending
Only non-simple requests are blocked by a failing preflight. Requiring a JSON content type or a custom header helps, plus SameSite and tokens.
42. An internal service on
http://192.168.0.10should not be reachable by scripts on public websites. What browser mechanism addresses this?Correct answer: Private Network Access protections in the browser
Routers and dev servers have been attacked from web pages. Still, internal services must authenticate requests themselves.
43. Why do preflights hurt performance in an API-heavy SPA, and how can you reduce them?
Correct answer: Each adds a round trip; use one origin or
Max-AgeServing the API under the app's origin (
/api) removes CORS entirely. Preflight caching is per URL and capped by browsers.44. What does
'strict-dynamic'in a CSP do?Content-Security-Policy: script-src 'nonce-abc' 'strict-dynamic'; object-src 'none'; base-uri 'none'Correct answer: Scripts loaded by a trusted script are trusted too
This makes strict CSP practical with bundlers and loaders, without long, bypassable domain allowlists.
45. Why are host-allowlist CSPs like
script-src 'self' https://cdn.example.comoften bypassable?Correct answer: Allowed hosts may serve JSONP or script gadgets
Research found most allowlist-based policies could be bypassed. Nonce or hash-based strict CSP avoids this.
46. Why should a strict CSP include
base-uri 'none'(or'self')?Correct answer: An injected
<base>could redirect scriptsEven nonced scripts loaded by relative path would follow the injected base URL.
47. How do you roll out a new CSP without breaking production?
Correct answer: Start with
Content-Security-Policy-Report-OnlyReport-only mode shows what would be blocked without blocking it. Expect noise from extensions in the reports.
48. What do Trusted Types enforce?
Content-Security-Policy: require-trusted-types-for 'script'Correct answer: DOM sinks accept only policy-created typed objects
This turns DOM XSS into a reviewable problem: only a few policy functions can create HTML, and they can sanitize it.
49. What is mutation XSS (mXSS)?
Correct answer: Sanitized HTML turns dangerous after re-parsing
This is why sanitizers must use the browser's own parser and be kept up to date, and why output should not be parsed twice.
50. What is DOM clobbering?
<a id="config" href="https://evil.example"></a> <script> const url = window.config?.href || "/default.js"; </script>Correct answer: Injected
idornameattributes override globalsEven sanitized HTML without scripts can clobber globals. Avoid reading config from globals and use explicit declarations.
51. Why is it better to encode output for its context than to filter 'bad' input once on arrival?
Correct answer: Each output context needs a different encoding
Validate input for business rules, but escape at the point of output using context-aware templating.
52. What does an
HttpOnlysession cookie NOT protect against when there's XSS?Correct answer: The script making authenticated requests as the user
The attacker can't steal the cookie, but can still act as the user while the page is open. Preventing XSS remains essential.
53. What is the danger of injecting server data into an inline script like this?
<script> window.__STATE__ = ${JSON.stringify(state)}; </script>Correct answer: A string with
</script>closes the tag earlyEscape
<as\u003cwhen embedding JSON in HTML, or put data in atype="application/json"script and parse it.54. Where should HTML from users be sanitized in a system that renders it in a web app and a mobile app?
Correct answer: At output in each client, keeping the original stored
Sanitizers and rendering contexts change over time. Sanitizing at render time with up-to-date rules protects against stored payloads.
55. What does the
__Host-cookie name prefix guarantee?Set-Cookie: __Host-session=abc; Secure; Path=/; HttpOnly; SameSite=LaxCorrect answer: It was set over HTTPS by this exact host
It defends against cookie tossing from a compromised or user-controlled subdomain.
56. Why doesn't
SameSiteprotect against attacks from a compromised subdomain likeblog.example.com?Correct answer: Subdomains count as the same site
Same-site attacks need other defenses: CSRF tokens,
__Host-cookies, Fetch Metadata and careful subdomain hygiene.57. What does CHIPS (
Partitionedcookies) change for an embedded widget?Set-Cookie: __Host-widget=1; Secure; Path=/; SameSite=None; PartitionedCorrect answer: It gets a separate cookie jar per top-level site
A chat widget embedded on
a.comandb.comkeeps state on each, but the two states can't be joined.58. What happens when an origin's storage exceeds the browser's quota or the device runs low on disk?
Correct answer: The browser may evict the origin's best-effort storage
navigator.storage.persist()requests persistent storage;estimate()reports usage and quota. Offline apps must handle eviction.59. What is storage partitioning in modern browsers?
Correct answer: Third-party storage is keyed by the top site
It also covers the HTTP cache: a resource cached while on site A isn't reused on site B, closing cache-timing leaks.
60. Why can a single large HTML document still have a slow TTFB with HTTP/3 and a CDN?
Correct answer: An uncacheable page still waits for the origin
Protocols reduce connection costs, not server work. Edge caching of HTML, streaming and faster backends address that part.
61. What does HTTP/2 connection coalescing allow?
Correct answer: Reusing one connection for several hostnames
This saves handshakes, but splitting assets across many domains (old 'sharding') usually hurts more than it helps today.
62. Why is 'domain sharding' an anti-pattern with HTTP/2?
Correct answer: It adds lookups and handshakes, and splits priorities
Sharding helped with HTTP/1.1's per-host connection limits. With multiplexing, one connection is more efficient.
63. What does TLS 1.3 improve for page load compared to TLS 1.2?
Correct answer: A full handshake takes one round trip, not two
0-RTT data can be replayed, so servers should accept it only for idempotent requests.
64. What's the point of
Link: <...>; rel=preloadsent as an HTTP header instead of in HTML?Correct answer: The fetch can start before any HTML is parsed
It's useful when the HTML is slow to generate or when you can't edit the markup.
65. Why is a sandboxed iframe on a separate origin a common way to render untrusted HTML (e.g. user-generated widgets)?
<iframe sandbox="allow-scripts" src="https://usercontent.example-cdn.com/widget/42"></iframe>Correct answer: The code can't reach the app's DOM or cookies
This is why services host user content on separate domains. Never combine
allow-scriptswithallow-same-originfor same-origin content.66. Why is
allow-scripts allow-same-originon a sandboxed iframe with same-origin content dangerous?Correct answer: The framed script can remove its own sandbox
With both flags, same-origin content is effectively unsandboxed. Use a separate origin for untrusted content.
67. What is the purpose of HSTS preloading?
Correct answer: The domain is built into browsers as HTTPS-only
It requires
includeSubDomainsand a longmax-age, and removal is slow, so all subdomains must support HTTPS first.68. Which approach to third-party scripts limits both performance and security risk the most?
Correct answer: Inventory them, pin with SRI, restrict with CSP
Each third-party script runs with your origin's privileges and on your main thread; supply chain attacks often come through them.
69. Why should the CSP be sent as an HTTP header rather than a
<meta>tag when possible?Correct answer: Some directives don't work in
<meta>at allA meta CSP is a fallback for static hosting where you can't control headers.
70. What does a service worker mean for XSS impact?
Correct answer: A malicious service worker can persist across visits
Restrict the SW script path, avoid registering workers from user-controlled URLs and keep
Clear-Site-Dataready for incident response.71. What is the most important limitation of a Web Application Firewall (WAF) against XSS?
Correct answer: Payloads can slip past its signatures
A WAF is defense in depth. Context-aware encoding, sanitizers, CSP and Trusted Types are what actually fix XSS.
72. What's the main idea of the RAIL performance model?
Correct answer: User-centered goals for response, animation, idle, load
RAIL frames performance around user perception. Core Web Vitals turned similar goals into measurable field metrics.
73. The hero heading fades in with an animation from
opacity: 0. How can this affect LCP?Correct answer: Zero-opacity elements aren't LCP candidates
Entrance animations on the main content trade a nice effect for a later LCP. Keep the LCP element visible from the first paint.
74. Why do 'anti-flicker' snippets of client-side A/B testing tools often hurt LCP?
Correct answer: They hide the page until the experiment is applied
A slow testing script delays all content. Server-side or edge-side experiments avoid hiding the page.
75. Why doesn't loading a popular font from a public font CDN benefit from other sites' caches anymore?
Correct answer: Browsers partition the HTTP cache by top-level site
The shared-cache argument is gone, while the extra connection to another origin remains. Self-hosting fonts is often faster.