What is the precise behavior of the browser’s event loop when a microtask queue contains pending tasks after a macrotask completes?

Web Development Hard

Web Development — Hard

What is the precise behavior of the browser’s event loop when a microtask queue contains pending tasks after a macrotask completes?

Key points

  • Microtasks have higher priority than macrotasks.
  • The microtask queue is fully drained before the next event loop iteration.
  • Rendering typically occurs after the microtask queue is empty.
  • Recursive microtasks can block the event loop indefinitely.

Ready to go further?

Related questions