JavaScript · Middle · Question 26 of 75

What is requestAnimationFrame for?

Explanation

The callback is synced with the screen refresh rate and isn't called in background tabs, saving resources. Animation via setTimeout(fn, 16) can drift out of sync with frames and stutter.

Further reading

Problem with a question

JavaScript · Middle · question 26

Test yourself

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

Take this quiz