Browser & Web Performance · Middle · Question 4 of 75
Why is requestAnimationFrame better than setInterval(fn, 16) for visual updates?
- 1It guarantees exactly 60 frames per second on every device
- 2It runs on a separate thread
- ✓Correct answer: It runs right before the browser renders the next frame and pauses in background tabs
Explanation
Timers drift and aren't aligned with frames, so updates can be dropped or done twice. rAF also adapts to 120 Hz displays.