Skip to content

FlashcardNot attempted

The event loop

Recall it before you reveal

Explain the browser event loop: call stack, microtasks, macrotasks and rendering.

Space to reveal
Show answer & explanation

1. Run one task (script, timer callback, event handler) until the call stack is empty. 2. Drain the microtask queue completely: promise callbacks, queueMicrotask, await continuations. Microtasks queued meanwhile run in the same drain. 3. Maybe render: requestAnimationFrame callbacks, then style, layout, paint (~every 16ms). 4. Take the next task.

So: sync → all microtasks → (render) → next timer. A chain of microtasks that never ends starves rendering.