Browser and UI
A frontend engineer interview on browser rendering, page speed, UI state and data fetching, accessibility, layout, and front-end security and testing.
These prompts are original practice. They are not questions from a named employer or a live hiring loop.
1.A fitness tracker sorts a large workout log inside a click handler. The sort takes about 400 ms, and during that time the pressed button shows no visual change. What is the most likely reason?
2.What does this code log?
console.log('A'); setTimeout(() =>console.log('B'), 0); Promise.resolve().then(() =>console.log('C'));console.log('D');3.A seed catalog renders 2,000 rows, each with its own click listener. Rows added later by infinite scroll do not respond to clicks. What is the cleanest fix?
4.In a ferry ticket app, a link's click handler calls event.stopPropagation(), yet the browser still navigates to the link's URL. Why?
5.A bakery order tracker animates a progress bar with setInterval every 16 ms. The motion looks uneven on several laptops. What is the better approach?
6.A developer writes a function that calls Promise.resolve().
then(itself)in a loop to process a queue. The page freezes and never repaints. Why?7.A tax estimate tool parses a 30 MB CSV file in the browser, and the whole page freezes for several seconds. What is the most effective change?
8.A trail map page has a touchmove listener that only sends analytics and never calls preventDefault. Scrolling on phones feels sticky. What helps most?
9.A county library search box sends a request on every keystroke. A teammate suggests debouncing the input. What does debouncing do?
10.A recipe site loops over 500 cards. For each card it reads offsetHeight, then sets style.height. The loop takes over a second. What is the main cause?
11.A property listing page reads and writes element sizes in the same loop, causing layout thrashing. What is the most direct fix?
12.A hotel booking site slides a side drawer open by animating its CSS left property. The motion stutters on mid-range phones. What should change?
13.After a style change, in what order does a browser typically do the work needed to update the screen?
14.Changing which of these CSS properties usually triggers paint but not layout?
15.A museum website puts a 400 KB stylesheet in the head. On slow connections, users stare at a blank screen for seconds. Why does the stylesheet cause this?
16.A dental clinic site loads a 200 KB script with a plain script tag in the head, and the page content appears late. What change lets the HTML render sooner while keeping script order?
17.To make a news feed feel smoother, a developer adds will-change: transform to every element. Memory use on phones jumps and some tabs crash. Why?
18.A co-op accounting ledger renders 20,000 rows at once. Scrolling is slow and the first render takes several seconds. What is the most effective approach?
19.What does the Largest Contentful Paint (LCP) metric measure?
20.On a cooking blog, the article text jumps down when an ad loads above it. Which Core Web Vital does this hurt, and what is the usual fix?
21.In a grocery delivery app, tapping Add to cart runs 600 ms of work before the button updates. Which Core Web Vital will flag this, and what helps?
22.A travel site's hero photo is the Largest Contentful Paint (LCP) element, and it has loading="lazy". LCP is poor. What should change first?
23.A lab audit of a university admissions portal scores 98, but field data from real users shows poor Largest Contentful Paint. What best explains the gap?
24.On a law firm blog, paragraphs reflow when the custom web font replaces the fallback font, causing layout shift. What reduces this most?
25.The marketing team says a bike-share signup page feels slow, but nobody knows why. What should you do first?
26.A permit portal has slow Largest Contentful Paint. The network waterfall shows the HTML document itself takes 2.1 seconds to arrive. Where should you focus?
27.In browser performance tools, what counts as a long task?
28.A utility billing site embeds a third-party chat widget that adds 300 KB of script and blocks the main thread on load. What is the best change?
29.A school district app bundles a large charting library into the main bundle, but charts appear only on the reports page. What is the best fix?
30.A team imports one helper function from a utility library, yet the bundle still contains the whole library. What is a likely reason?
31.After a merge, a shop's main JavaScript bundle grows from 180 KB to 900 KB and the size check in CI fails. What do you do first?
32.On a real estate site, phones download a 3,000-pixel-wide photo for a slot that displays at 400 pixels wide. What fixes this?
33.Why set width and height attributes on img tags even when CSS makes the images responsive?
34.A photography club gallery serves large JPEG files. Which change usually cuts the most bytes with little visible loss?
35.On slow networks, a pottery studio site shows blank space where text should be for up to three seconds while its web font loads. What fixes this?
36.A web font is referenced only from a stylesheet that is itself imported by another stylesheet, so the browser finds it late. What speeds up its arrival?
37.A hiking blog's long article loads 40 images as soon as the page opens. What improves initial load the most without hurting the main image?
38.After each release of a pet adoption site, some users keep running old JavaScript for days. What caching setup prevents this?
39.What best describes the difference between server state and client UI state in a frontend app?
40.A hardware store app keeps both items and filteredItems in component state. After edits, the two lists often disagree. What is the best fix?
41.A React child wrapped in React.memo still re-renders every time its parent does. The parent passes style={{ margin: 8 }}. Why?
42.A teammate wraps nearly every calculation in a React component with useMemo. How do you respond in code review?
43.A volunteer roster renders editable rows using the array index as the key. Deleting the second row makes the third row's input show the deleted row's text. Why?
44.A quiz app keeps the theme and a once-per-second countdown in the same React context. The whole app re-renders every second. What fixes this?
45.Two sibling components on a parking permit form both need the currently selected zone. Where should that state live?
46.Inside useEffect with an empty dependency array, a component starts setInterval that logs count. The log always shows 0, even after count changes. Why?
47.A handler calls
setCount(count + 1)three times in a row, but count goes up by only one. What explains this, and what fixes it?48.A form component uses useEffect to set fullName whenever firstName or lastName changes. What is the better approach?
49.What makes a text input controlled in React?
50.A credit union profile form shows a warning that an input changed from uncontrolled to controlled. Its value prop comes from state that starts as undefined. What fixes it?
51.A shipping form shows red errors under every empty field as soon as the page loads. What is a better validation timing?
52.A charity site relies on client-side checks to block negative donation amounts. Why is this not enough?
53.On a ticket resale site, some users are charged twice when they double-click Pay. What combination best prevents duplicate charges?
54.On a garden center site, pressing Enter in the search field does nothing. The search control is a div with an onClick handler. What is the right fix?
55.An insurance claim form has 200 controlled fields whose state lives in the top-level component. Typing in any field lags. What helps most?
56.Password managers fail to offer to fill or save credentials on a gym membership signup form. What should you check first?
57.In a movie theater app, typing "ca" then "cat" quickly sometimes leaves results for "ca" on screen. What is the correct fix?
58.A React effect fetches profile data whenever the selected user changes. What should the effect's cleanup function do?
59.A bike repair shop dashboard briefly shows "No orders found" before the real orders appear. What is the best fix?
60.A weather app shows a blank panel instead of an error message when the API returns HTTP 500. The code wraps fetch in try/catch. Why is no error shown?
61.A page fetches the user, then a child component fetches orders once it renders, then a grandchild fetches shipping info. None of these depend on each other. What helps most?
62.A photo club site updates the like count right away when a user taps Like. The server request then fails. What should the UI do?
63.What does a stale-while-revalidate strategy do in a client data cache?
64.A classifieds board uses infinite scroll with page numbers and offsets. When new listings are posted, users see duplicate items while scrolling. Why?
65.A farmers market app is used on spotty rural networks, and many requests fail. What is the best handling approach?
66.In React, what does an error boundary catch?
67.A clinic scheduler has a Save control built from a div with a click handler. Keyboard users cannot use it. What is the best fix?
68.A florist site has a purely decorative swirl image between sections. How should its alt attribute be set?
69.In a moving company app, closing a dialog sends keyboard focus back to the top of the page. Where should focus go?
70.While a confirmation dialog is open, pressing Tab moves focus to links in the page behind it. What should happen instead?
71.What is a sound first rule when you are about to add Accessible Rich Internet Applications (ARIA) attributes?
72.In a hardware rental checkout, the order total updates when items change, but screen reader users get no indication. What helps?
73.Help text in a payroll app is light gray on white. Under Web Content Accessibility Guidelines (WCAG) level AA, what contrast does normal-size body text need?
74.A loan application marks invalid fields only by turning their border red. Why is this a problem, and what fixes it?
75.A sign-up form for a swim school uses placeholder text as the only label for each field. What is the main problem?
76.A city council site styles section titles as bold, large div elements instead of heading tags. Why does this matter for accessibility?
77.A designer asks to set outline: none on all buttons and links because the focus ring looks unpolished. What do you recommend?
78.A transit agency site has a long navigation menu at the top of every page. What does adding a skip link provide?
79.A close button on a newsletter popup has aria-hidden="true" set on the button element itself. What problem does this cause?
80.In a note-taking app, a trash-can icon button is announced by screen readers only as "button". What is the right fix?
81.You are building a custom select-style dropdown for a recipe filter. Which keyboard behavior should it support?
82.An automated accessibility checker reports zero issues on a museum ticketing site. Is the site accessible?
83.Users of a planetarium site report dizziness from large parallax scrolling effects. What is the right response?
84.A conference schedule needs cards in a layout where both rows and columns line up. Which CSS tool fits best?
85.A new mobile site for a food truck shows a tiny zoomed-out desktop layout on phones, even though media queries exist. What is most likely missing?
86.A button has class btn. The stylesheet contains #header .btn { color: white; } followed later by .btn { color: black; }. Which color applies inside #header?
87.A sidebar is set to width: 300px with 20px of padding on each side, and it renders 340 pixels wide. How do you make it exactly 300 pixels including padding?
88.A full-screen hero set to height: 100vh is partly hidden behind the browser toolbar on phones. What is the modern fix?
89.In a flex row, a child containing a long unbroken URL overflows its container instead of shrinking. What is the usual fix?
90.A rental listing card appears in a narrow sidebar and in a wide main column. It should change layout based on its own width, not the screen's. What fits?
91.A dropdown menu has z-index: 9999 but still appears behind a sibling panel with z-index: 10. What is the likely cause?
92.A hobby forum renders user comments by assigning them to innerHTML. A user posts a comment with an image tag whose onerror runs a script. What is the right fix?
93.What does a Content Security Policy (CSP) header mainly help with?
94.A single-page app for a coworking space stores its access token in localStorage. What is the main risk?
95.A team moves its session into a cookie with the HttpOnly flag. What does that flag do, and what is still needed?
96.What does setting a cookie's SameSite attribute to Lax do?
97.A React wiki converts user-written markdown to HTML and renders it with dangerouslySetInnerHTML. What must happen before rendering?
98.A profile page lets users enter a personal website, rendered as a link's href. A user enters javascript:
alert(document.cookie). What should the app do?99.A developer says the API is safe from attackers because CORS is configured strictly. What is wrong with that claim?
100.A frontend developer puts a payment provider's secret API key in a build-time environment variable used by browser code. What is the problem?
101.UI tests for a vet clinic app find elements by CSS class names, and they break whenever designers restyle the page. What is the better approach?
102.A test clicks Load more, sleeps for two seconds, then checks the list. It fails now and then in CI. What is the best fix?
103.A component test for a carpool app asserts the value of an internal state variable after a click. How should it be improved?
104.For component tests of a screen that fetches data, which mocking approach keeps tests closest to real behavior?
105.A team building a checkout flow asks how to split its UI tests. What is a sound plan?
106.A component test that checks whether a tooltip fits on screen passes in jsdom, but the tooltip overflows in real browsers. Why did the test miss it?
107.A feature is turned on by parsing the user agent string for known browser versions. It breaks when a browser ships a new version. What is the better approach?
108.A site uses Array.prototype.at, and some older browsers throw an error. The team already transpiles its code. Why did that not fix it?
109.new
Date('2026-03-04 10:00')returns a valid date in one browser and Invalid Date in another. What is the most reliable fix?110.A small team must decide which browsers and devices to test an airport parking kiosk app on before launch. How should they choose?