AnimationTimeline: currentTime property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.

The currentTime read-only property of the Web Animations API's AnimationTimeline interface returns the timeline's current time in milliseconds, or null if the timeline is inactive.

Value

A number representing the timeline's current time in milliseconds, or null if the timeline is inactive.

Reduced time precision

To offer protection against timing attacks and fingerprinting, the precision of animationTimeline.currentTime may be reduced depending on browser settings.

The current time normally advances with animation frames. Reading the property repeatedly while a script runs does not provide a continuously updating clock.

For a DocumentTimeline, the current time is calculated by subtracting the originTime offset, which can be supplied by script, from the browser's animation clock.

In Chrome, the rounding interval for the animation clock during rendering updates is 0.1 ms, or 0.005 ms in cross-origin-isolated contexts. The browser does not apply additional timer rounding after subtracting originTime.

In Safari, the rounding interval for the animation clock is 1 ms, or 0.02 ms in cross-origin-isolated contexts. After subtracting originTime, the browser rounds the returned value to 0.001 ms, the resolution used to represent animation times.

In Firefox, after subtracting originTime, the browser rounds the returned value to 0.02 ms by default, including in cross-origin-isolated contexts. If privacy.resistFingerprinting is enabled, the rounding interval is 16.667 ms or the interval configured by privacy.resistFingerprinting.reduceTimerPrecision.microseconds, whichever is larger.

For example, these are possible values in Firefox:

js
// Reduced time precision (0.02 ms) with default settings
animationTimeline.currentTime;
// Might be:
// 23.4
// 24.18
// 25.5
// …

// Reduced time precision with `privacy.resistFingerprinting` enabled
animationTimeline.currentTime;
// Might be:
// 50.001
// 66.668
// 83.335
// …

Specifications

Specification
Web Animations
# dom-animationtimeline-currenttime

Browser compatibility

See also