Performance and Security
Web vitals, rendering cost, caching, and browser-side security basics.
Web Performance and Browser Security Basics
Know web vitals, bundle cost, rendering cost, XSS, and safe frontend data handling.
Beginner interview questions
Start with simple definitions, the main idea, and the basic mistakes interviewers expect you to avoid.
Performance means the site feels fast and stable. Security means the browser should not trust the wrong content.
Performance means the site feels fast and stable. Security means the browser should not trust the wrong content. Easy picture: A good school gate should be wide enough for quick entry and strict enough to stop strangers from entering the classrooms.
A good school gate should be wide enough for quick entry and strict enough to stop strangers from entering the classrooms.
Interviewers often begin with a basic question to see whether you truly understand the concept instead of repeating memorized jargon.
- Measure loading, responsiveness, and layout stability.
- Reduce JS cost and expensive rendering work.
- Never trust raw user HTML.
LCP-style thinking: main content speed. Responsiveness depends on main-thread availability. Avoid layout shift. Sanitize untrusted HTML.
LCP-style thinking: main content speed. Responsiveness depends on main-thread availability. Avoid layout shift. Sanitize untrusted HTML.
A good school gate should be wide enough for quick entry and strict enough to stop strangers from entering the classrooms.
This checks whether you can give a short, calm answer before the interviewer adds depth or follow-ups.
- Talking only about Lighthouse scores.
- Injecting unsanitized HTML.
1-3 Years interview questions
Cover common screening and theory questions that prove you know the fundamentals and can answer clearly.
Measure loading, responsiveness, and layout stability. Reduce JS cost and expensive rendering work. Never trust raw user HTML. Security and performance both affect user trust.
Measure loading, responsiveness, and layout stability. Reduce JS cost and expensive rendering work. Never trust raw user HTML. Security and performance both affect user trust.
A good school gate should be wide enough for quick entry and strict enough to stop strangers from entering the classrooms.
This checks whether you can give a clean interview answer without getting lost in too much detail.
- LCP-style thinking: main content speed.
- Responsiveness depends on main-thread availability.
- Avoid layout shift.
Performance: web vitals, bundle size, rendering cost, caching. Security: XSS, safe HTML rendering, token handling, and browser trust boundaries.
For performance I talk about loading speed, responsiveness, layout stability, bundle strategy, and heavy main-thread work. For security I talk about sanitizing untrusted HTML, escaping dynamic content, understanding client-side token risks, and keeping browser trust boundaries explicit.
const safeMessage = DOMPurify.sanitize(userHtml); return <div dangerouslySetInnerHTML={{ __html: safeMessage }} />;
This is a common interview question used to test clarity, correctness, and how calmly you explain fundamentals.
- How would you reduce LCP?
- When is dangerouslySetInnerHTML acceptable?
3-6 Years interview questions
Focus on mid-level answers with practical examples, tradeoffs, and implementation thinking.
Performance means the site feels fast and stable. Security means the browser should not trust the wrong content.
For performance I focus on core web vitals, bundle size, image strategy, caching, and main-thread work. For security I focus on escaping untrusted content, sanitizing user HTML, careful token handling, and understanding the browser trust boundary. I present both as user-trust problems, not only technical scores.
const safeMessage = DOMPurify.sanitize(userHtml); return <div dangerouslySetInnerHTML={{ __html: safeMessage }} />;
Mid-level rounds expect more than definitions. They want structured explanation, correct terminology, and practical judgment.
- Measure loading, responsiveness, and layout stability.
- Reduce JS cost and expensive rendering work.
- Never trust raw user HTML.
- Security and performance both affect user trust.
Performance: web vitals, bundle size, rendering cost, caching. Security: XSS, safe HTML rendering, token handling, and browser trust boundaries.
For performance I talk about loading speed, responsiveness, layout stability, bundle strategy, and heavy main-thread work. For security I talk about sanitizing untrusted HTML, escaping dynamic content, understanding client-side token risks, and keeping browser trust boundaries explicit.
const safeMessage = DOMPurify.sanitize(userHtml); return <div dangerouslySetInnerHTML={{ __html: safeMessage }} />;
This is a common interview question used to test whether your fundamentals are clear, practical, and easy to explain.
- How would you reduce LCP?
- When is dangerouslySetInnerHTML acceptable?
Expert interview questions
Practice high-signal follow-ups around architecture, pitfalls, debugging, scale, and leadership-level judgment.
Performance means the site feels fast and stable. Security means the browser should not trust the wrong content. The main thing to avoid is: Talking only about Lighthouse scores.
For performance I focus on core web vitals, bundle size, image strategy, caching, and main-thread work. For security I focus on escaping untrusted content, sanitizing user HTML, careful token handling, and understanding the browser trust boundary. I present both as user-trust problems, not only technical scores. Common pitfalls: Talking only about Lighthouse scores. Injecting unsanitized HTML. Speaking about security only in backend terms. Related areas to connect in follow-ups: React Performance Toolkit, Frontend System Design: Search and Dashboard Thinking.
const safeMessage = DOMPurify.sanitize(userHtml); return <div dangerouslySetInnerHTML={{ __html: safeMessage }} />;
Senior-leaning interviewers test whether you can move from definitions into tradeoffs, debugging, scale, and connected system thinking.
- What real bug or production issue can this topic cause?
- What tradeoff would make you choose one approach over another?
- How would you explain this decision in a code review or design discussion?
Loading Strategy, Caching, and Core Web Vitals
Answer LCP, CLS, INP, image strategy, caching, and bundle questions with product-level clarity.
Beginner interview questions
Start with simple definitions, the main idea, and the basic mistakes interviewers expect you to avoid.
Fast apps load important content quickly, stay stable while loading, and respond without delay when the user interacts.
Fast apps load important content quickly, stay stable while loading, and respond without delay when the user interacts. Easy picture: A good shop opens the front door first, keeps the shelves from moving around, and serves the first customer quickly instead of making everyone wait for every room to be cleaned.
A good shop opens the front door first, keeps the shelves from moving around, and serves the first customer quickly instead of making everyone wait for every room to be cleaned.
Interviewers often begin with a basic question to see whether you truly understand the concept instead of repeating memorized jargon.
- LCP is about major content arriving quickly.
- CLS is about layout staying stable.
- INP is about responsive interactions.
Prioritize critical content. Keep dimensions stable. Ship less JavaScript upfront. Cache with freshness in mind.
Prioritize critical content. Keep dimensions stable. Ship less JavaScript upfront. Cache with freshness in mind.
A good shop opens the front door first, keeps the shelves from moving around, and serves the first customer quickly instead of making everyone wait for every room to be cleaned.
This checks whether you can give a short, calm answer before the interviewer adds depth or follow-ups.
- Reciting metric names without explaining user impact.
- Preloading too many assets and hurting network priority.
Performance: web vitals, bundle size, rendering cost, caching. Security: XSS, safe HTML rendering, token handling, and browser trust boundaries.
For performance I talk about loading speed, responsiveness, layout stability, bundle strategy, and heavy main-thread work. For security I talk about sanitizing untrusted HTML, escaping dynamic content, understanding client-side token risks, and keeping browser trust boundaries explicit.
const image = <img src={heroUrl} width={960} height={540} loading="eager" alt="Dashboard preview" />; // Use stable dimensions and prioritize only truly critical media.
This is a common interview question used to test whether your fundamentals are clear, practical, and easy to explain.
- How would you reduce LCP?
- When is dangerouslySetInnerHTML acceptable?
1-3 Years interview questions
Cover common screening and theory questions that prove you know the fundamentals and can answer clearly.
LCP is about major content arriving quickly. CLS is about layout staying stable. INP is about responsive interactions. Caching and priority decisions shape all three.
LCP is about major content arriving quickly. CLS is about layout staying stable. INP is about responsive interactions. Caching and priority decisions shape all three.
A good shop opens the front door first, keeps the shelves from moving around, and serves the first customer quickly instead of making everyone wait for every room to be cleaned.
This checks whether you can give a clean interview answer without getting lost in too much detail.
- Prioritize critical content.
- Keep dimensions stable.
- Ship less JavaScript upfront.
3-6 Years interview questions
Focus on mid-level answers with practical examples, tradeoffs, and implementation thinking.
Fast apps load important content quickly, stay stable while loading, and respond without delay when the user interacts.
I frame performance around what the user feels: how quickly the main content appears, whether the layout jumps, and how fast interactions respond. Then I connect that to concrete fixes like route splitting, image optimization, caching policy, preloading critical assets, reducing third-party script cost, and keeping the main thread free for interaction. I also distinguish static asset caching from API freshness strategies.
const image = <img src={heroUrl} width={960} height={540} loading="eager" alt="Dashboard preview" />; // Use stable dimensions and prioritize only truly critical media.
Mid-level rounds expect more than definitions. They want structured explanation, correct terminology, and practical judgment.
- LCP is about major content arriving quickly.
- CLS is about layout staying stable.
- INP is about responsive interactions.
- Caching and priority decisions shape all three.
Focus on the main content first: reduce heavy JavaScript, optimize the hero asset, improve server response, and prioritize only critical resources.
I explain LCP as the time for the main visible content to appear. Then I mention concrete levers: smaller bundles, route splitting, reducing render-blocking assets, compressing and sizing the hero image, preloading only key resources, and improving server or CDN response. I also mention that third-party scripts and unnecessary client-side work often hurt LCP more than teams expect.
const image = <img src={heroUrl} width={960} height={540} loading="eager" alt="Dashboard preview" />; // Use stable dimensions and prioritize only truly critical media.
This checks your decision-making, tradeoffs, and ability to discuss the bigger picture.
- How can image dimensions help performance?
- Why can too much preloading backfire?
Static assets can usually be cached very aggressively when filenames are versioned, but API data needs freshness rules and user-visible fallback behavior.
I explain that asset caching and data caching are different. Build assets with content hashes can be cached for a long time because new content produces a new URL. API data needs freshness decisions like polling, revalidation, optimistic updates, or stale-while-refresh patterns. A good answer also mentions how the UI communicates loading, staleness, and retry behavior instead of hiding those states.
const image = <img src={heroUrl} width={960} height={540} loading="eager" alt="Dashboard preview" />; // Use stable dimensions and prioritize only truly critical media.
This checks your decision-making, tradeoffs, and ability to discuss the bigger picture.
- When would you revalidate in the background?
- How do you prevent users from trusting stale numbers?
Expert interview questions
Practice high-signal follow-ups around architecture, pitfalls, debugging, scale, and leadership-level judgment.
Fast apps load important content quickly, stay stable while loading, and respond without delay when the user interacts. The main thing to avoid is: Reciting metric names without explaining user impact.
I frame performance around what the user feels: how quickly the main content appears, whether the layout jumps, and how fast interactions respond. Then I connect that to concrete fixes like route splitting, image optimization, caching policy, preloading critical assets, reducing third-party script cost, and keeping the main thread free for interaction. I also distinguish static asset caching from API freshness strategies. Common pitfalls: Reciting metric names without explaining user impact. Preloading too many assets and hurting network priority. Treating asset caching and API caching as the same problem. Related areas to connect in follow-ups: Web Performance and Browser Security Basics, Browser Render Pipeline and Main Thread Thinking, Realtime Dashboards and Resilient Data Flow.
const image = <img src={heroUrl} width={960} height={540} loading="eager" alt="Dashboard preview" />; // Use stable dimensions and prioritize only truly critical media.
Senior-leaning interviewers test whether you can move from definitions into tradeoffs, debugging, scale, and connected system thinking.
- What real bug or production issue can this topic cause?
- What tradeoff would make you choose one approach over another?
- How would you explain this decision in a code review or design discussion?
Frontend Security, Auth, and Trust Boundaries
Explain XSS, CSRF, token storage, CSP, sanitization, and what frontend can and cannot guarantee.
Beginner interview questions
Start with simple definitions, the main idea, and the basic mistakes interviewers expect you to avoid.
Frontend code runs in the user's browser, so it should never trust unsafe input and should never pretend it can hide secrets perfectly.
Frontend code runs in the user's browser, so it should never trust unsafe input and should never pretend it can hide secrets perfectly. Easy picture: A classroom monitor can check who enters, but the master key should still stay in the office, not under the desk.
A classroom monitor can check who enters, but the master key should still stay in the office, not under the desk.
Interviewers often begin with a basic question to see whether you truly understand the concept instead of repeating memorized jargon.
- Frontend should reduce risk, not invent trust.
- Escape or sanitize untrusted content.
- Token storage has tradeoffs, not magic answers.
Never trust raw HTML. Know cookie versus token tradeoffs. Use CSP as extra protection. Server remains the source of truth.
Never trust raw HTML. Know cookie versus token tradeoffs. Use CSP as extra protection. Server remains the source of truth.
A classroom monitor can check who enters, but the master key should still stay in the office, not under the desk.
This checks whether you can give a short, calm answer before the interviewer adds depth or follow-ups.
- Storing secrets in the client and calling it secure.
- Using dangerouslySetInnerHTML without sanitization.
1-3 Years interview questions
Cover common screening and theory questions that prove you know the fundamentals and can answer clearly.
Frontend should reduce risk, not invent trust. Escape or sanitize untrusted content. Token storage has tradeoffs, not magic answers. Client checks help UX but server checks protect data.
Frontend should reduce risk, not invent trust. Escape or sanitize untrusted content. Token storage has tradeoffs, not magic answers. Client checks help UX but server checks protect data.
A classroom monitor can check who enters, but the master key should still stay in the office, not under the desk.
This checks whether you can give a clean interview answer without getting lost in too much detail.
- Never trust raw HTML.
- Know cookie versus token tradeoffs.
- Use CSP as extra protection.
XSS, unsafe HTML rendering, weak token handling assumptions, exposed client logic, and insecure third-party integrations are high-frequency frontend risks.
I begin with XSS because it directly affects how browsers execute untrusted content. Then I mention unsafe HTML injection, token and session handling tradeoffs, trusting the client too much, insecure third-party scripts, and the role of CSP and validation. I also clarify that frontend can reduce risk but cannot become the final authority for access control or sensitive business rules.
function SafePreview({ html }: { html: string }) { const safeHtml = DOMPurify.sanitize(html); return <div dangerouslySetInnerHTML={{ __html: safeHtml }} />;
This is a common interview question used to test clarity, correctness, and how calmly you explain fundamentals.
- When is dangerouslySetInnerHTML acceptable?
- What does CSP help with?
3-6 Years interview questions
Focus on mid-level answers with practical examples, tradeoffs, and implementation thinking.
Frontend code runs in the user's browser, so it should never trust unsafe input and should never pretend it can hide secrets perfectly.
I explain security by trust boundaries. The browser UI can reduce risk, but the client is not a trusted secret store. I discuss escaping dynamic content, sanitizing allowed HTML, understanding token tradeoffs, CSRF implications with cookies, CSP as defense in depth, and avoiding dangerous assumptions like hiding sensitive logic only in the frontend. I also separate authentication, authorization, and UI convenience concerns.
function SafePreview({ html }: { html: string }) { const safeHtml = DOMPurify.sanitize(html); return <div dangerouslySetInnerHTML={{ __html: safeHtml }} />;
Mid-level rounds expect more than definitions. They want structured explanation, correct terminology, and practical judgment.
- Frontend should reduce risk, not invent trust.
- Escape or sanitize untrusted content.
- Token storage has tradeoffs, not magic answers.
- Client checks help UX but server checks protect data.
There is no perfect client-side answer. You choose based on threat model, UX, and server design, while keeping sensitive logic on the server.
A mature answer avoids pretending one storage option is universally safe. localStorage is convenient but exposed to XSS if the app is compromised. Cookies can reduce some manual handling but bring CSRF considerations and server coupling. I explain the tradeoffs, mention defense in depth like CSP and sanitization, and stress that frontend storage decisions cannot replace server-side authorization and session design.
function SafePreview({ html }: { html: string }) { const safeHtml = DOMPurify.sanitize(html); return <div dangerouslySetInnerHTML={{ __html: safeHtml }} />;
This checks your decision-making, tradeoffs, and ability to discuss the bigger picture.
- Why is 'never use localStorage' too simplistic?
- How do cookies change the CSRF discussion?
Expert interview questions
Practice high-signal follow-ups around architecture, pitfalls, debugging, scale, and leadership-level judgment.
Frontend code runs in the user's browser, so it should never trust unsafe input and should never pretend it can hide secrets perfectly. The main thing to avoid is: Storing secrets in the client and calling it secure.
I explain security by trust boundaries. The browser UI can reduce risk, but the client is not a trusted secret store. I discuss escaping dynamic content, sanitizing allowed HTML, understanding token tradeoffs, CSRF implications with cookies, CSP as defense in depth, and avoiding dangerous assumptions like hiding sensitive logic only in the frontend. I also separate authentication, authorization, and UI convenience concerns. Common pitfalls: Storing secrets in the client and calling it secure. Using dangerouslySetInnerHTML without sanitization. Talking about auth and authorization as the same thing. Related areas to connect in follow-ups: Web Performance and Browser Security Basics, Browser Storage, Caching, and Networking, Frontend System Design: Search and Dashboard Thinking.
function SafePreview({ html }: { html: string }) { const safeHtml = DOMPurify.sanitize(html); return <div dangerouslySetInnerHTML={{ __html: safeHtml }} />;
Senior-leaning interviewers test whether you can move from definitions into tradeoffs, debugging, scale, and connected system thinking.
- What real bug or production issue can this topic cause?
- What tradeoff would make you choose one approach over another?
- How would you explain this decision in a code review or design discussion?
Performance and Security Questions from Source Library
Imported performance and security interview questions.
Beginner interview questions
Start with simple definitions, the main idea, and the basic mistakes interviewers expect you to avoid.
This topic groups questions about speed, rendering cost, caching, XSS, and safe frontend behavior.
This topic groups questions about speed, rendering cost, caching, XSS, and safe frontend behavior. Easy picture: It is the part of the exam about making the site fast and safe at the same time.
It is the part of the exam about making the site fast and safe at the same time.
Interviewers often begin with a basic question to see whether you truly understand the concept instead of repeating memorized jargon.
- Measure user speed.
- Reduce main-thread work.
- Sanitize untrusted HTML.
Speed matters. Stability matters. Sanitize data. Think like a user and attacker.
Speed matters. Stability matters. Sanitize data. Think like a user and attacker.
It is the part of the exam about making the site fast and safe at the same time.
This checks whether you can give a short, calm answer before the interviewer adds depth or follow-ups.
- Talking only about scores and forgetting users.
- Trusting unsanitized data.
1-3 Years interview questions
Cover common screening and theory questions that prove you know the fundamentals and can answer clearly.
Measure user speed. Reduce main-thread work. Sanitize untrusted HTML. Explain trust boundaries.
Measure user speed. Reduce main-thread work. Sanitize untrusted HTML. Explain trust boundaries.
It is the part of the exam about making the site fast and safe at the same time.
This checks whether you can give a clean interview answer without getting lost in too much detail.
- Speed matters.
- Stability matters.
- Sanitize data.
3-6 Years interview questions
Focus on mid-level answers with practical examples, tradeoffs, and implementation thinking.
This topic groups questions about speed, rendering cost, caching, XSS, and safe frontend behavior.
This section covers frontend performance and security questions around web vitals, bundle strategy, rendering cost, sanitization, token handling, and trust boundaries.
const safeHtml = DOMPurify.sanitize(userHtml);
Mid-level rounds expect more than definitions. They want structured explanation, correct terminology, and practical judgment.
- Measure user speed.
- Reduce main-thread work.
- Sanitize untrusted HTML.
- Explain trust boundaries.
This topic groups questions about speed, rendering cost, caching, XSS, and safe frontend behavior.
This section covers frontend performance and security questions around web vitals, bundle strategy, rendering cost, sanitization, token handling, and trust boundaries.
const safeHtml = DOMPurify.sanitize(userHtml);
This is a common interview question used to test whether your fundamentals are clear, practical, and easy to explain.
- Measure user speed.
- Reduce main-thread work.
- Talking only about scores and forgetting users.
Expert interview questions
Practice high-signal follow-ups around architecture, pitfalls, debugging, scale, and leadership-level judgment.
This topic groups questions about speed, rendering cost, caching, XSS, and safe frontend behavior. The main thing to avoid is: Talking only about scores and forgetting users.
This section covers frontend performance and security questions around web vitals, bundle strategy, rendering cost, sanitization, token handling, and trust boundaries. Common pitfalls: Talking only about scores and forgetting users. Trusting unsanitized data. Related areas to connect in follow-ups: Web Performance and Browser Security Basics, React Performance Toolkit.
const safeHtml = DOMPurify.sanitize(userHtml);
Senior-leaning interviewers test whether you can move from definitions into tradeoffs, debugging, scale, and connected system thinking.
- What real bug or production issue can this topic cause?
- What tradeoff would make you choose one approach over another?
- How would you explain this decision in a code review or design discussion?