requestAnimationFrame takes a callback function. How/when it is called, depends on the API of the higher-order function (i.e. the function/method that takes the callback).
In the case of requestAnimationFrame I believe the “event” that drives it is timing based.
Window: requestAnimationFrame() method - Web APIs | MDN
callbackThe function to call when it’s time to update your animation for the next repaint. The callback function is passed one single argument, a
DOMHighResTimeStampsimilar to the one returned byperformance.now(), indicating the point in time whenrequestAnimationFrame()starts to execute callback functions.
For a more broad look into scheduling/queuing by the engine/runtime.