What goes in the macrotask queue in JavaScript?
setTimeout, setInterval, setImmediate (Node.js), I/O callbacks (network, file system), UI events (click, input, scroll), MessageChannel, and postMessage callbacks.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Microtask Queue vs Macrotask Queue in JavaScript
Microtasks (Promise.then, queueMicrotask) are drained completely before any macrotask and before rendering. Macrotasks (setTimeout, events, I/O) run one at a time with microtasks drained after each. Microtasks have higher priority.
Because promise callbacks go to the microtask queue, which the event loop drains completely before taking any macrotask from the macrotask queue where setTimeout callbacks live. Microtasks always run first.
Promise.then, .catch, .finally callbacks, queueMicrotask(fn), MutationObserver callbacks, and process.nextTick (Node.js, even higher priority than promises).
Still have questions?
Browse all our FAQs or reach out to our support team
