Hint
rAF fires in the render phase of the event loop β before paint but after microtasks. setTimeout(0) fires as a macrotask after the render phase.
setTimeout(() => console.log('timeout'), 0);
requestAnimationFrame(() => console.log('rAF'));
Promise.resolve().then(() => console.log('microtask'));
console.log('sync');sync microtask rAF timeout
Explanation: "sync" first. Microtask drains: "microtask". Then browser render phase fires: rAF runs just before paint. Then macrotask: "timeout". (Note: exact rAF vs timeout order can vary by browser implementation, but rAF typically precedes setTimeout in the same frame.)
Key Insight: rAF fires in the render phase of the event loop β before paint but after microtasks. setTimeout(0) fires as a macrotask after the render phase.