requestAnimationFrame()

A function that schedules a callback to run just before the browser's next repaint, the right place to update animations.

In more detail

The callback receives a high-resolution timestamp for smooth timing. Browsers pause these callbacks in hidden tabs, saving power. Unlike setTimeout it stays in step with the display.

Related terms

Taught in

References