Event Loop Visualizer

This interactive model teaches the JavaScript runtime at an educational level: stack-first execution, then microtasks, then tasks. Use the examples to see why Promise.thencallbacks run before setTimeout(..., 0) callbacks.

Simplifications are intentional. We represent time as discrete ticks, model a single task queue, and treat awaitcontinuation as an immediately settled microtask.

Shows stack-first execution with no queued async work.

  • Synchronous statements run immediately in order.
  • The call stack must clear before the loop checks queues.

Controls

Playback speed

Tick: 0

Executing global() on the sync queue.

Call stack

Top frame is the currently executing function/context.

  1. global()

    source: sync • next op 1/3 active

Microtask queue

Promise callbacks and async continuations.

  1. No microtasks queued.

Task queue

Macrotasks like timeout callbacks.

  1. No tasks queued.

Timers

Waiting for their due tick before entering task queue.

  1. No pending timers.

Execution timeline

Ordered log of what happened and why.

  1. t0Script start

    Started example: Simple synchronous flow

Subscribe via RSS

Copyright © 2020 - 2026 Alex Leung