coderef

requestAnimationFrame()Baseline · Widely available

The requestAnimationFrame() method schedules a function that runs before the next repaint. You can use it to animate content with JavaScript.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jul 29, 2015. Widely available since Jan 29, 2018.

Browser support

DesktopChrome
1–23Not supported
24+Supportedsince Jan 10, 2013
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1–22Not supported
23+Supportedsince Aug 6, 2013
Current: 157
Safari
1–6Not supported
7+Supportedsince Oct 22, 2013
Current: 27
MobileChrome Android
18–18Not supported
25+Supportedsince Feb 27, 2013
Current: 155
Firefox Android
4–22Not supported
23+Supportedsince Aug 6, 2013
Current: 157
Safari iOS
1–6Not supported
7+Supportedsince Sep 18, 2013
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: cancelAnimationFrame.

Feature detection

JS · check before using
if ("Window" in globalThis && "requestAnimationFrame" in Window.prototype) {
  // Window.requestAnimationFrame is available
}

Sub-features

Support for each part of the feature (2). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Window.cancelAnimationFrame241223725237
Window.requestAnimationFrame241223725237