JavaScript:requestAnimationFrame
lastmod 2026-11-10created 2022-01-272 edits
requestAnimationFrame is a Window method that asks the browser to call a specified callback just before it repaints the next frame. Because it runs in sync with the display refresh rate and pauses when the tab is hidden, it is smoother and uses fewer resources than running animations with setTimeout or setInterval. The callback must be requested again on every frame.