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
- id: C1 claim: A task is any discrete piece of work the browser does. source: S1 evidence: "A task is any discrete piece of work that the browser does"
- id: C2 claim: The main thread can process only one task at a time. source: S1 evidence: "The main thread can only process one task at a time"
- id: C3 claim: A task longer than 50 milliseconds is a long task. source: S1 evidence: "Any task that takes longer than 50 milliseconds is a long task"
- id: C4 claim: Each agent has its own event loop. source: S2 evidence: "Each agent has an associated event loop"
- id: C5 claim: An event loop has one or more task queues. source: S2 evidence: "An event loop has one or more task queues"
- id: C6 claim: The microtask queue is not a task queue. source: S2 evidence: "The microtask queue is not a task queue"
Sources
- [S1] Optimize long tasks. web.dev. https://web.dev/articles/optimize-long-tasks . License: CC-BY-4.0. Accessed 2026-11-23.
- [S2] HTML Living Standard, Web application APIs. WHATWG. https://html.spec.whatwg.org/multipage/webappapis.html . License: CC-BY-4.0. Accessed 2026-11-23.
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
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.},
}
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.
- javascript-long-tasks.schema.json (schema; CC-BY-4.0)
- javascript-long-tasks.table.json (table; CC-BY-4.0)
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.