IT lexicon › Programming › Microtask

Microtask

Programming På svenska → Updated: 2026-11-15

A high-priority job in the browser's event loop that runs before the next macrotask or paint.

The event loop has two queues: microtasks (Promise callbacks, MutationObserver, queueMicrotask) and macrotasks (setTimeout, I/O, UI events). After each macrotask, the entire microtask queue drains before the browser updates styles, layout, or paint. Microtasks are faster but risky: if a microtask spawns new microtasks, it can starve rendering indefinitely.

Frameworks like Vue, React, and Zone.js use microtasks for reactive updates and change detection. A microtask is often the right choice when you need to batch DOM updates without yielding to the browser, but overuse causes "jank" and can freeze input responsiveness.

← Back to the lexicon