Using requestAnimationFrame

This code shows how to use requestAnamitionFrame to optimize animation.