-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are multiple intervals created? #9
Comments
Hi Šime! I'll look into the performance difference of using one interval function. Creating one for each wasn't an optimization design decision, it just seemed clearer to me while programming. By the way I really appreciate Web Platform Daily : ) |
Let me preface this by saying: I may understand timers incorrectly, so please correct me if this is the case.
takes between 0 and 1ms to complete for a single image (it’s rudimentary, but jsperf is down). Say we have 100 unloaded images that need to be checked continuously, that’s already a significant amount of time, roughly 50-100ms in total. The question is whether we want to set a single Now compare that with the current implementation of setting 100 individual Does that make sense? |
I think the memory overhead of dealing with an arbitrary amount of interval'd functions (the current method) may be worse than having one rather large interval function (@simevidas's proposed method). I think I'll make some test pages with an insane amount of scroll-loading images and measure the memory usage for each method. The best way to close this issue imo is to use some generally approved polyfill for intersection observer. Work for this is being done here w3c/IntersectionObserver#121. |
If I’ve read the code correctly, multiple
setInterval
timers are created (one per image). Could this be optimized? I’m not sure if this is a micro-optimization, but I don’t like the idea of having multiple timers in the event loop. If the images could share o single timer, that would be better, I think.The text was updated successfully, but these errors were encountered: