
The browser
- What does the browser do between receiving HTML and showing the page? A good answer covers parsing, the DOM and the CSS object model, render-blocking CSS and scripts, layout, paint and compositing, and where the critical path can be shortened.
- What is the difference between layout, paint and compositing, and why does it matter for animation? A good answer explains that animating transform and opacity can stay on the compositor, while animating width or position forces layout on every frame.
- Explain the event loop using a promise and a setTimeout. A good answer says promise callbacks run as microtasks before the next task, that long tasks block input, and can predict the output order of a small example.
- Why does a request fail with a CORS error, and how do you fix it? A good answer explains that the browser enforces the rule and the server opts in with headers, that some requests send a preflight first, and that the fix belongs on the server.
- Where should a web app keep a sign-in token? A good answer compares an HttpOnly, secure cookie, which scripts cannot read but needs protection against cross-site requests, with local storage, which any script on the page can read.
- What causes memory leaks in a single-page app? A good answer names listeners and timers that are never removed, subscriptions kept after a component is gone, caches that only grow and detached DOM nodes, and finds them with heap snapshots.
JavaScript and TypeScript
- What is a closure, and where have you used one on purpose? A good answer explains that a function keeps access to the variables where it was created, gives a real use such as an event handler, and knows the stale closure bug in React hooks.
- When does TypeScript not protect you? A good answer points at runtime boundaries: API responses, parsed JSON, the any type and type assertions, and validates outside data where it enters the app.
- How would you build a search box that queries as you type? A good answer debounces the input, cancels or ignores stale requests so an old result cannot replace a newer one, and shows loading and empty states.
- How do you handle errors in asynchronous code? A good answer uses try and catch around awaited calls, avoids promises that nobody handles, adds error boundaries for rendering, and shows the user something useful.
- What does a bundler do, and how do you make a bundle smaller? A good answer explains module resolution, transforms, code splitting and minifying, and makes the bundle smaller by splitting by route, removing heavy dependencies and checking with a bundle analyzer.
Components and state
- How do you decide where state lives? A good answer keeps state close to where it is used, lifts it only when it is shared, keeps server data in a data-fetching cache instead of global state, and puts state that should survive a reload in the URL.
- Why does a component re-render, and when should you care? A good answer names state, props and context changes, says most re-renders are cheap, and measures with a profiler before adding memoization.
- Controlled or uncontrolled form inputs? A good answer uses controlled inputs for live validation and dependent fields, uncontrolled ones for simple forms, and labels and error messages that screen readers announce either way.
- How would you build a table with sorting, filtering and 10,000 rows? A good answer pages on the server or virtualizes the rows, uses stable keys, sorts where the data lives and keeps filters in the URL.
- What is hydration, and what causes a hydration mismatch? A good answer explains that server HTML is made interactive in the browser, and that dates, random values and browser-only APIs during render make the two disagree.
- When would you render on the server and when in the browser? A good answer renders on the server for fast first loads and search engines, in the browser for highly interactive signed-in screens, and statically when content rarely changes.
Performance
- A page is slow on phones. Where do you start? A good answer measures first, with real-user data and a throttled lab run, then fixes the biggest problem: the largest image, render-blocking files, long tasks or too much JavaScript.
- What are Core Web Vitals, and how would you improve the largest contentful paint? A good answer names LCP, INP and CLS, and improves LCP by prioritizing the main image, preloading fonts, cutting render-blocking CSS and reducing server time.
- What causes layout shift, and how do you prevent it? A good answer names images without dimensions, late fonts, ads and content injected above what the user is reading, and reserves space for each.
- How do you load images well? A good answer serves the right size in a modern format, uses srcset and sizes, lazy-loads images below the fold and never lazy-loads the main image.
Accessibility, security and quality
- How do you make a custom dropdown accessible? A good answer prefers the native element, and otherwise adds the right roles, keyboard support for the arrows, Escape and Enter, focus management and labels, then tests it with a screen reader.
- What do you check in an accessibility review? A good answer checks heading order, labels, color contrast, keyboard-only use, a visible focus, alt text and reduced-motion settings.
- How do you test a frontend? A good answer uses unit tests for logic, component tests that act like a user, a few end-to-end tests for the flows that make money, and visual checks where layout matters.
- How do you stop a third-party script from slowing the page? A good answer loads it asynchronously or after interaction, measures what it costs, and holds it to a performance budget.
- How do you prevent cross-site scripting in a modern framework? A good answer knows frameworks escape output by default, watches raw HTML insertion, links built from user input and third-party scripts, and adds a Content Security Policy as a second layer.
Behavioral, for frontend roles
- Tell me about a disagreement with a designer. A good answer shows they understood the design goal, brought evidence such as usability, cost or accessibility, and reached a decision together.
- Tell me about a bug that only some users saw. A good answer explains how they narrowed it down by browser, device, language or data, how they reproduced it and how they kept it from coming back.
- How do you keep a design system consistent across teams? A good answer uses shared components and tokens, documentation with examples, a path for proposing new patterns and removing one-off copies.
- What did you ship that you are proud of, and what would you change? A good answer names a specific screen or feature, their part in it, a measured result and one honest improvement.
How to practice these
- Pick the five questions you would find hardest, not the ones you already know.
- Answer each one out loud in about two minutes, and record yourself if you can.
- Compare your answer with the note: did it cover what a good answer shows?
- For every question, write down one real example from your own work that you could use.
For interviewers: the notes work as a scoring guide. Decide before the interview what a strong answer covers, and score the evidence you heard, not the confidence it was said with. See how to run a fair technical interview.
More roles and the questions every engineer gets: interview questions by role.