There are a lot of ways to break up long tasks in JavaScript.
Dead simple list of potential ways to break up long tasks, allowing the main thread to process other things. scheduler.yield() seems like the most obvious choice, but nice that the article includes a simple polyfill for non-Chromium browsers too.