The click handler runs to completion as a single task. Every microtask it queued, including resolved promise callbacks, drains next, before anything else happens. Only then, if a frame is due, does the browser run requestAnimationFrame callbacks and go through style, layout, paint and composite. A long task or an endless chain of microtasks delays that frame, and users read the delay as jank.
Why interviewers ask this
Almost all frontend performance work comes down to knowing what blocks the frame. The interviewer wants to hear that scripting, style, layout and paint share one main thread, that microtasks are not a way to yield back to the browser, and that requestAnimationFrame exists for work that must land before paint. It also predicts whether you can debug a responsiveness complaint or will just scatter setTimeout calls until the symptom moves.
How to structure your answer
- Name the three phases in order: task, microtask drain, rendering opportunity.
- Point out that microtasks starve the renderer while a timeout yields.
- Say where requestAnimationFrame sits relative to style and layout.
- Connect it to a metric such as interaction latency.
Example answer
The handler itself is one task on the main thread, so it runs start to finish with nothing interrupting it. As soon as it returns, the browser drains the microtask queue, so any await continuation or promise then callback runs right there, and if those keep queuing more microtasks the browser never gets a chance to paint. Once that queue is empty, and only if a frame is actually due, the browser runs any requestAnimationFrame callbacks, recalculates style, does layout, paints and composites. That is why I treat long tasks as the real enemy. On a dashboard I worked on, a filter change did a synchronous sort of about forty thousand rows in the handler, and the click felt dead for roughly two hundred milliseconds. Splitting it so the handler only updated the input, then yielding with scheduler.yield before the expensive pass, kept the frame budget intact and the interaction started responding immediately even though the total work was identical.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- Why does awaiting a resolved promise not give the browser a chance to paint?
- When would you reach for requestAnimationFrame instead of a timeout?
- How would you break up a long task without changing the result?
Related frontend developer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions