A busy JavaScript task can leave a page looking frozen: the browser suspends visual updates while JavaScript runs. Rendering can happen between tasks, but not before queued microtasks run. section 13.1.2 section 13.2.2
Figure 13.9. A page can be re-rendered between two macrotasks (mainline JavaScript execution and first click handler), while it can’t be rendered before a microtask is executed (before the promise handler).
This timing diagram shows where a page may be re-rendered relative to macrotasks and a promise microtask. section 13.1.2
For expensive work, such as building thousands of DOM rows, split processing into chunks and schedule later chunks with a timer. This gives the event loop opportunities to handle other work instead of letting one long task monopolize execution. section 13.2.2
