Saved for my personal reference, all content belongs to codetheory.in
Limiting the frame rate while using requestAnimationFrame
can be a common want especially when coding Games where you want your animations and mechanics to not exceed a particular mark of frames per second. Let’s go through 2 ways of doing it.
Using setTimeout
inside the rAF method is an easy way.