JS EXPERTChapter 9 · JS Expert
Microtasks and the Event Loop
JavaScript is single-threaded but runs concurrently via the Event Loop. Promises queue jobs in the Microtask Queue, executing before rendering or the callback macrotask queue.
Worked example
How it reads
- Microtasks (Promise then, queueMicrotask) run immediately after current script
- Macrotasks (setTimeout, event callbacks) run in subsequent tick loops

Cloud tip: Never block the event loop with long CPU-bound synchronous loops, or UI rendering will freeze.


