Conclusion
All in all, this is pretty exciting. The requestAnimationFrame
function brings to the table the same level of optimization your animations or transitions created in CSS have. Instead of your code telling the browser to redraw the screen and the browser (being the temperamental thing that it is) ignoring that request, the requestAnimationFrame
politely asks the browser to call the animation loop when it is ready to redraw the screen. This cordial relationship results in really smooth animations. See! Being nice always pays off…if you are a JavaScript function!