Web APIs

requestAnimationFrame()

Try the free JavaScript compiler

Requests a one-shot rendering callback receiving a timestamp. The request ID can cancel a pending callback.

Formal Syntax & Structure

javascript syntaxjavascript
requestAnimationFrame(callback)

Parameters & Attributes

NameTypeDescription
callbackfunctionFrame callback accepting a timestamp.

Return Value

number

Request ID.

Working Example

Example Snippetjavascript
(async () => {const t=await new Promise(resolve=>requestAnimationFrame(resolve));console.log(typeof t,Number.isFinite(t));})()
JavaScript Reference