Here's what happens:
you declare a function definition, call the requestAnimationFrame function.
What schedule will your function call and execute again when the time is right, namely the next frame , which is usually after 16 ms. In addition, this scheduling is asynchronous. This will not stop the code below. Thus, it does not look like the code below this line will not work until 16 ms.
However, in most cases, the function is performed within 3-4 ms.
But if the function had to take longer to finish the next frame, it would be delayed, thus not fulfilling the scheduled task, which should again call the same function.
In a sense, animation is an endless loop. What requestAnimationFrame is intended to be. However, this non-blocking infinite loop is limited to frames / fps .
Muhammad Umer
source share