As I understand it, usage of the JS requestAnimationFrame
API is intended for cases where the framerate isn\'t in need of being controlled, but I have a use cas
Yoshi's answer is probably the best code solution to this problem. But still I'll mark this answer as correct, because after some research I basically found that my question was invalid. requestAnimationFrame
is really meant to keep frame rates as high as possible, and it optimizes for scenarios where animation is meant to be kept consistent and smooth.
Worth noting though is that you don't need requestAnimationFrame
to get optimization (even though rAF was touted as a great performance booster) since browsers still optimize regular drawing of a . For example, when a tab isn't focused, Chrome for one stops drawing its canvases.
So my conclusion was that this question was invalid. Hope this helps anyone who was wondering something similar to me.