Skip to content

The JavaScript Event Loop, Explained Explained

How JavaScript runs async code on one thread: each turn of the event loop empties the call stack, drains promise microtasks, then runs one macrotask, and why a long task freezes everything.

Animated diagrams · 3 flows

Compare all 3

Sort by any column to find the right fit. Click a name to open its details.

Micro vs Macro: the Racetwo queues, one threadmicro before macroone turn apartin-memory queuesLowCallback order puzzles
One Turn of the Loopstack, then micro, then macroturn by turnmicroseconds per turnin-memory queuesLowPredicting callback order
Starvation: the Long Taskblocked, then catch-up burstdelayed while blockedgrows with task lengthsingle threadLowDiagnosing frozen UI