To complement this, JavaScript is single threaded, so the next frame has to wait for any computation started before it was scheduled. That is why pages sometimes feel unresponsive. If you want to be really sure that the view was updated, you can wait for message from onAnimationFrame
before starting computation, or run it in a different web worker.
You might also be interested in those discussions:
- Long-running computations in Elm that won't freeze the page
- How to deal with blocking JS code (using ports)? (it seems you already participated in that conversation but still relevant)