The requestAnimationFrame API is the best way to do non-declarative animations in a power-efficient and smooth way. This API is similar to the setTimeout and setInterval APIs that developers use today, except that it notifies the application when it needs to update the screen, and only when it needs to update the screen. It keeps Web applications perfectly aligned with the painting of the window, and uses only the necessary amount of resources. This API will take page visibility and the display refresh rate into account to determine how many frames per second to allocate to the animation.
In this example, the clock is being animated using the requestAnimationFrame API.
Target frames per second: