requestAnimationFrame timing
Runs code before each screen refresh, and reveals the display's refresh rate.
In one line
Can run code before each screen refresh and learn your refresh rate
Runs code before each screen refresh, and reveals the display's refresh rate.
A site can learn your monitor's refresh rate (60, 120, 144 Hz) by counting frames, and can tell when the tab is hidden because callbacks stop. It is the core of smooth animation.
What it can and can't do
What the user does: Nothing. It happens when the page shows animation
It can
- Run smooth animations and games
- Count frames to learn your screen runs at 60, 120 or 144 Hz
- Tell when the tab is hidden, since the calls pause
It cannot
- Run while the tab is hidden in most browsers
- Ask permission first
- See your files
- Know who you are by itself
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 24 | 2013-01-10 | None |
| Edge | Supported | 12 | 2015-07-29 | None |
| Firefox | Supported | 23 | 2013-08-06 | None |
| Safari | Supported | 7 | 2013-10-22 | None |
| Safari on iPhone | Supported | 7 | 2013-09-18 | All iOS browsers use WebKit |
| Chrome on Android | Supported | 25 | 2013-02-27 | None |
| Samsung Internet | Supported | 1.5 | 2013-09-25 | None |
How a site asks for it
| API | requestAnimationFrame(cb); cb(timestamp) |
| Browser compat keys | api.Window.requestAnimationFrameapi.Window.cancelAnimationFrame |
| How access is granted | none |
| What the user sees | None (no browser prompt) |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| Activation | none |
| How long it lasts | Per page; callbacks run once per display refresh while the tab is visible |
| How to take it back | Nothing to revoke (no permission is stored) |
| Inside an iframe | Per frame; hidden iframes stop receiving callbacks |
Typical flow
- Page calls requestAnimationFrame
- Browser calls back before the next paint
- Page reads the DOMHighResTimeStamp argument
Data you get
Shape: none
No individual data fields. The signal is the access itself.
Technical limits
- Callbacks pause entirely in background tabs and hidden iframes in all major browsers (no hidden polling)
- Frame rate follows the display: 60 Hz gives about 16.7 ms between callbacks, 120 Hz gives about 8.3 ms
- Safari on iOS in Low Power Mode drops callbacks to about 30 fps
- Timestamps are rounded like performance.now() (coarse, with jitter)
- No access to the exact refresh rate; it must be measured
The story
What it is
A page runs code right before each screen refresh, which also reveals your display's refresh rate.
For you
You never see a prompt. It is why animations and games look smooth. When you switch tabs, the browser pauses it to save power. It also shows how fast your screen refreshes.
For makers
It is the heartbeat of every browser game and animation. It lets code draw in time with the screen and pause when hidden. The timing also reveals the refresh rate, which is a small device clue.
Where you see it
| Type | Example | Apps |
|---|---|---|
| games | A browser game like Krunker.io calls it every frame to move players and draw the scene. | Krunker.io, Slither.io |
| creative | A design tool redraws only when needed, in step with the screen, so panning stays smooth. | Figma, Excalidraw |
| maps | A web map redraws tiles and labels in each frame while you drag. | Google Maps, Mapbox |
| video | A video player draws overlays like subtitles in time with each frame. | None named |
| ads | An ad script uses frame timing to check the ad was truly on screen and not hidden in a background tab. | None named |
| security | A bot detector sees that frames never run, a sign of a hidden or headless browser. | None named |
| education | A science site animates a simulation, like planets in orbit, smoothly at the screen's speed. | None named |
Risks
- Reveals refresh rate
- Can reveal hidden tabs
What the platform says
- MDN: requestAnimationFrame. Tells the browser to run animation code just before the next screen refresh, for smooth motion.
Good uses and abuse
Legitimate uses
- Animation and games
- Canvas and WebGL rendering
- Scroll linked effects
Known abuse
- Refresh rate fingerprinting
- Detecting hidden tabs or low power mode
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 1 of 5 | How revealing the data is |
| Utility | 5 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | 2 | Rough identifying entropy, when known |
History
- 2013-01, Chrome 24: Unprefixed requestAnimationFrame
- 2013-08, Firefox 23: Unprefixed requestAnimationFrame
Related capabilities
Related
- Display refresh rate measurement. Can count frames to find your screen's refresh rate
- Background tab timer throttling. Can't keep its timers running fast once you switch to another tab
Sources
How well checked: Based on official documentation.