Replace setTimeout with requestAnimationFrame.

requestAnimationFrame is nice: https://developer.mozilla.org/en-US/docs/Web/API/window.requestAnimationFrame.

Here's a polyfill for older browsers so it falls back to setTimeout: https://gist.github.com/paulirish/1579671.