JavaScriptAdvanced
The JavaScript Event Loop: Tasks, Microtasks and Rendering
Why does a resolved promise always beat setTimeout(fn, 0)? Learn exactly how the event loop schedules tasks, microtasks and repaints, and how to keep long work from freezing the page.