In JavaScript, the animationstart event fires when a CSS Animation has started (MDN). If there is an animation-delay, it fires after that delay expires. A negative delay still fires the event, with elapsedTime equal to the absolute value of the delay.
Register a listener with addEventListener. Check readiness and browser support before you rely on this event.
Syntax
Listen for animationstart. Start with this line.
JavaScript
el.addEventListener("animationstart", fn)
Call
What it does
el.addEventListener("animationstart", fn)
Primary signature.
Built into the browser. Listen with el.addEventListener("animationstart", …) — no import required.
Library declarations
JavaScript
el.addEventListener("animationstart", fn)
Parameters
Parameter
Description
CSS animation
Required. Must actually start keyframes
animation-delay
Optional. Positive delay postpones the event
Return Value
Return Value
Description
*
Fires as an Element event (listener receives the Event object).
JavaScript Examples
Example 1 — Listen for animationstart (MDN)
Log a message as soon as the CSS animation begins.
animationstart (after delay)
/* appears ~0.5s after the animation is applied */
How It Works
Set a positive delay in CSS (for example 0.5s).
Apply the animation. The browser waits before starting playback.
Event fires after the delay — that is when the animation has started (MDN).
Try a negative delay in the lab to see a non-zero elapsedTime.
Compatibility
Browser Support
Element.animationstart is marked Baseline Widely available on MDN (since December 2019). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
Element animationstart
Fires when a CSS animation starts — after any positive animation-delay.
WidelyAvailable
Google ChromeFull support · Desktop & Mobile
Full support
Mozilla FirefoxFull support · Desktop & Mobile
Full support
Apple SafariFull support · macOS & iOS
Full support
Microsoft EdgeFull support · Chromium
Full support
OperaFull support · Modern versions
Full support
Internet ExplorerLegacy with prefixes historically
Partial support
animationstartBaseline support
Bottom line: Safe for modern browsers. Listen for animationstart after applying a CSS animation, and account for animation-delay. See the MDN Element animationstart reference.
Frequently Asked Questions
It fires when a CSS Animation has started (MDN). If there is an animation-delay, the event fires after that delay expires. With a negative delay, the event still fires and elapsedTime equals the absolute value of the delay.
No. MDN marks Element animationstart as Baseline Widely available (since December 2019). It is not Deprecated, Experimental, or Non-standard.
An AnimationEvent. Useful read-only properties include animationName, elapsedTime, and pseudoElement.
Use element.addEventListener("animationstart", handler) or set element.onanimationstart = handler. Prefer addEventListener when you need multiple handlers or easy removal.
Usually 0.0. If animation-delay is negative, elapsedTime is (-1 * delay) — for example a delay of -0.5s yields elapsedTime 0.5, and the animation begins partway through its sequence (MDN).
animationstart is first. Then you may get animationiteration between loops, animationend when the full run completes, or animationcancel if the animation aborts early.