requestAnimationFrame and Smooth Animations
A browser API for scheduling visual updates in sync with the display's refresh cycle, producing smoother animations than setTimeout-based approaches.
requestAnimationFrame (rAF) is a browser API specifically designed for scheduling code that updates the screen's visuals, synchronized precisely with the browser's own natural rendering cycle — typically matching the display's refresh rate (commonly 60Hz, meaning roughly every 16.7ms) — which produces visibly smoother, more efficient animations than driving the same updates with setTimeout or setInterval, which have no inherent awareness of the browser's actual rendering schedule at all.
requestAnimationFrame is like a stagehand who only makes their next scenery change exactly when the curtain is about to rise for the next scene, perfectly timed to the actual show's pacing — versus a stagehand on a fixed independent stopwatch (setTimeout) who might make changes mid-scene, out of sync with what the audience is actually about to see, wasting effort or causing visible jank either way.