Window: requestAnimationFrame() method - Web APIs | MDN
The window.requestAnimationFrame() method tells the browser you wish to perform an animation. It requests the browser to call a user-supplied callback function before the next repaint.