This repo is a companion to the following blog post, which does a bit of exploration into JavaScript's event loop, the browser's repaint cycle, and how we can reliably navigate the mix:
https://macarthur.me/posts/when-dom-updates-appear-to-be-asynchronous