Scienced

3D explainer

How the browser event loop works

Loading model 0%

01 / 10

One thread does almost everything

A page's JavaScript, its event handlers and most of the work of drawing it share a single thread: the main thread. It can only do one thing at a time.

The event loop is the rule that decides what that one thing is. Picture it as the bridge in the middle of this machine. It turns from lane to lane and lets one piece of work at a time onto the call stack, the only place where code runs.

Threads running the page's code
1

How the browser event loop works

One thread runs a page's JavaScript, answers every click and draws every frame. The event loop is the rule that decides what it does next: one task, then every microtask, then a frame if one is due.

By Antanas Misiunas · Version 1 · Nov 11, 2026

Sources

  1. HTML Standard: Event loops
  2. HTML Standard: Timers
  3. MDN: Microtasks and the JavaScript runtime environment
  4. W3C: Long Tasks API
  5. web.dev: Optimize long tasks

History

Every published version stays readable at its own address.

  1. v1

    Nov 11, 2026 · Current

    First published.