Skip to main content
JavaScript Interview Questions Concept Queue P0 Medium

A loading spinner never paints

A click handler shows a spinner and processes a large array in many small chunks. Each chunk uses queueMicrotask to schedule the next chunk. The spinner still doesn’t paint until processing ends. Why? Suggest one way to keep the UI responsive.

Official Reference

Model Answer & Explanation

The browser drains queued microtasks, including new ones they enqueue, before it can move on to the next task or take a rendering opportunity. Repeated microtasks do not yield to rendering. Split the work across tasks with bounded chunks, or move heavy CPU work into a Web Worker and leave the main thread free for the UI.

What a Strong Answer Covers

  • Distinguish yielding within a microtask checkpoint from yielding to a new task.
  • Offer a fix that lets the browser render and handle input.
Follow-up Interview Question · Would replacing queueMicrotask with await Promise.resolve() fix this? Why?

Module Context & References

JavaScript · Applied concepts Debug real scenarios and explain the rule behind each fix.
Personal Notes · Markdown

Technologies & Interview Topics Covered

Switch between short-term interview tracks and long-term 80/20 engineering depth to practice JavaScript internals, React rendering and hooks, timed frontend machine coding UI challenges, MeetaPro FG300, Blind 75 & NeetCode 150 DSA patterns, Python & FastAPI APIs, PostgreSQL query optimization & MVCC, Redis caching, Applied AI RAG pipelines & evaluations, and distributed system design.