Browser & Web Performance · Middle · Question 4 of 75

Why is requestAnimationFrame better than setInterval(fn, 16) for visual updates?

Explanation

Timers drift and aren't aligned with frames, so updates can be dropped or done twice. rAF also adapts to 120 Hz displays.

Further reading

Problem with a question

Browser & Web Performance · Middle · question 4

Test yourself

Take the Browser & Web Performance · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz