JavaScript · Senior · Question 1 of 75
How does the event loop process tasks in the browser?
- ✓Correct answer: One macrotask, then the whole microtask queue, then a possible render
- 2All macrotasks in a row, then one microtask, then a mandatory render
- 3Micro- and macrotasks strictly alternate one after another
Explanation
After each macrotask (script, event, timer), the microtask queue is drained completely, including microtasks added along the way. Then the browser may update rendering (calling requestAnimationFrame) if it's time for a frame. That's why a long chain of microtasks also blocks rendering.