1. Home
  2. Javascript
  3. Request animation frame

Request animation frame lets you line-up changes for the next window paint.

#javascript
function update() {
    
    // Animate elements here

    window.requestAnimationFrame(update);
  }
}

window.requestAnimationFrame(update);
copy
Full Javascript cheatsheet