react-waypoint icon indicating copy to clipboard operation
react-waypoint copied to clipboard

Break up onNextTick() queue consumption into ~50ms chunks

Open lencioni opened this issue 8 years ago • 3 comments

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!

lencioni avatar May 19 '17 18:05 lencioni

Makes sense to me.

jamesplease avatar May 19 '17 18:05 jamesplease

Me too. Have fun traveling!

trotzig avatar May 19 '17 19:05 trotzig

Other note is that setTimeout is not that good see this demo. Consider using setImmediate.

stereobooster avatar May 29 '17 17:05 stereobooster