← All notes

Long tasks: work on the main thread that lasts over 50 ms

Answer: A task is any discrete piece of work that the browser does. The main thread can only process one task at a time. Work lasting over 50 milliseconds is a long task. HTML gives each agent an event loop with task queues.

What counts as a task

web.dev treats a task as a discrete unit of browser work: rendering, parsing HTML and CSS, running JavaScript, and other work you may not control.

The main thread and long tasks

Most of this work, and almost all JavaScript you write, runs on the main thread.

Only one task is processed on the main thread at a time.

A task lasting longer than 50 milliseconds is called a long task.

How HTML models the event loop

User agents use event loops to coordinate events, scripts, rendering, and networking.

Each agent has an associated event loop, unique to that agent.

An event loop has one or more task queues, and a task queue is a set of tasks.

The microtask queue is not a task queue.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: web.dev, Optimize long tasks; WHATWG, HTML Living Standard, Web application APIs. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://raw.githubusercontent.com/whatwg/html/main/LICENSE). Copyright WHATWG contributors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: web.dev, Optimize long tasks; WHATWG, HTML Living Standard, Web application APIs. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://raw.githubusercontent.com/whatwg/html/main/LICENSE). Copyright WHATWG contributors.

Cite this

Permanent ID: iil:note:q0nwdfv1

iinventedlight. 2026. "Long tasks: work on the main thread that lasts over 50 ms." iinventedlight Library, iil:note:q0nwdfv1, version of 2026-11-23. https://iinventedlight.com/library/notes/javascript-long-tasks/. License: CC-BY-4.0.

@misc{iil_note_q0nwdfv1,
  author = {{iinventedlight}},
  title = {{Long tasks: work on the main thread that lasts over 50 ms}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/javascript-long-tasks/},
  note = {Permanent ID iil:note:q0nwdfv1. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/javascript-long-tasks.md.