requestAnimationFrame
requestAnimationFrame is a browser API method that schedules a callback to run before the next visual rendering update.
HTML5 in Action
requestAnimationFrame is a browser API method that schedules a callback before the next repaint.
- How it is used
- Schedules drawing callbacks for a Canvas game animation loop.
- How deep it goes
- Explains frame-rate fluctuations and two approaches to consistent movement, while deferring construction of a delta.
- Examples
- Uses a Canvas game engine and an x += 1 * delta movement update.
- What you can do after
- Apply requestAnimationFrame to Canvas animation and account for fluctuating frame rates in movement logic.
Web Components in Action
requestAnimationFrame is a browser API that schedules a callback to run before the next screen repaint.
- How it is used
- Coordinates animation or graphics updates with the browser’s render cycle.
- How deep it goes
- Explains one-shot callbacks, explicit rescheduling, visual updates, and an inheritable per-frame component pattern.
- Examples
- Uses a green visual countdown timer that shrinks each frame and resets after reaching zero.
- What you can do after
- Apply it via a recurring callback loop to animate a custom element on each browser frame.
Read how Web Components in Action explains requestAnimationFrame →
Math for Web Design
requestAnimationFrame is a browser API method that schedules a callback to run before the next repaint.
- How it is used
- Uses requestAnimationFrame() for time-based animations, circular motion, and throttled scroll-driven visual effects.
- How deep it goes
- Explains repeated callback scheduling within animation loops, but does not detail browser rendering internals.
- Examples
- Demonstrates circular motion and geometric parallax scrolling through JavaScript listings.
- What you can do after
- Build it from scratch for circular motion or throttle scroll-based parallax updates with JavaScript and CSS transforms.
Read how Math for Web Design explains requestAnimationFrame →
Also covered in
- JavaScript in DepthIn early access (MEAP)
What to know first
- coordinateA coordinate is a numerical value, or one component of an ordered set of values, specifying a position relative to a coordinate system.
- CSSCSS (Cascading Style Sheets) is a stylesheet language for specifying the presentation and layout of structured documents.
Related concepts
- setIntervalalternative to · setInterval is a JavaScript timer function that repeatedly schedules a callback to run after a specified interval until canceled.
- fade inused by · A fade-in is an animation technique that gradually increases an element’s opacity until it becomes fully visible.
- polyfillimplemented by · A polyfill is code that provides a compatible implementation of a platform or language feature missing from an execution environment.
- animationimplements · Animation is the presentation of changing visual states over time to create the appearance of motion or change.
- JavaScriptused by · JavaScript is a high-level, dynamically typed programming language standardized as ECMAScript and used for web and general-purpose programming.
Questions about requestAnimationFrame
What is requestAnimationFrame?
requestAnimationFrame is a browser API method that schedules a callback to run before the next visual rendering update.
Which Manning books explain requestAnimationFrame?
HTML5 in Action, Web Components in Action and Math for Web Design.
What should I know before learning requestAnimationFrame?
Manning books that teach requestAnimationFrame usually introduce coordinate and CSS first.
What is the difference between requestAnimationFrame and setInterval?
requestAnimationFrame is a browser API method that schedules a callback to run before the next visual rendering update. setInterval is a JavaScript timer function that repeatedly schedules a callback to run after a specified interval until canceled.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


