Break up onNextTick() queue consumption into ~50ms chunks
In #188 I merged an attempt to improve startup time of rendering many waypoints on the same page by clustering all of the timeouts from the initial render into one. This has a side-effect of causing all of the waypoints to execute in the same call stack, which might peg the main thread longer than we like.
In order to keep the browser responsive, I think it would make sense to, when consuming the timeoutQueue to check and see if it has been 50ms or more (preferring performance.now if it is available) and if it has, pause the queue consumption and call a new setTimeout to resume it.
I'll be traveling for a while so I won't be able to dig into this for a while, but I'd like to hear other people's thoughts and if someone else wants to pick this up that would be wonderful!
Makes sense to me.
Me too. Have fun traveling!
Other note is that setTimeout is not that good see this demo. Consider using setImmediate.