JavaScript Document timeline Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

Document.timeline is a read-only property that returns the document’s default DocumentTimeline — the special timeline used by the Web Animations API (MDN).

Read the notes below before you get or set this property. Prefer feature detection when support is limited.

Syntax

Use document.timeline. Start with this line.

JavaScript
document.timeline
CallWhat it does
document.timelinePrimary signature.

Built into the browser. Read or assign document.timeline — no import required.

Library declarations
JavaScript
document.timeline

Parameters

ParameterDescription
GetterRequired. Default DocumentTimeline
SetterOptional. Read-only

Return Value

Return ValueDescription
*The current value of document.timeline.

JavaScript Examples

Example 1 — Read document.timeline

Confirm the default timeline object type.

JavaScript
const tl = document.timeline;
console.log(tl.constructor.name);  // "DocumentTimeline"
console.log(tl === document.timeline); // true
Try It Yourself

How It Works

  1. Read the getter. Returns the document’s default timeline.
  2. Check the type. Constructor name is usually DocumentTimeline.
  3. Same instance. Repeated reads return the same object.
  4. Do not assign. The property is read-only.

Example 2 — Read currentTime

MDN: milliseconds since Performance.timeOrigin while active.

JavaScript
const t = document.timeline.currentTime;
console.log(t);            // e.g. 1842.3
console.log(t === null);   // false on a normal page
Try It Yourself

How It Works

  1. Read currentTime. Inherited from AnimationTimeline.
  2. Active document. On a normal page you get a number of milliseconds.
  3. Inactive → null. Before the time origin or on a non-active document (MDN).
  4. Advances over time. Reading again later yields a larger value.

Example 3 — Animate on the Default Timeline

Show that element.animate() runs on document.timeline by default.

JavaScript
const box = document.querySelector("#box");
const anim = box.animate(
  [{ opacity: 1 }, { opacity: 0.2 }],
  { duration: 500, iterations: 1 }
);

console.log(anim.timeline === document.timeline); // true
console.log(document.getAnimations().length >= 1);
Try It Yourself

How It Works

  1. Create an animation. animate() uses the document timeline by default.
  2. Compare timelines. anim.timeline === document.timeline.
  3. List animations. getAnimations() can see that animation while it runs.
  4. Keep demos short. A 500 ms opacity change is enough to prove the link.

Browser Support

Document.timeline is Baseline Widely available (MDN: since July 2020). Safe to use in modern evergreen browsers as part of Web Animations.

✓ Baseline · Widely available

Document.timeline

Default DocumentTimeline — established across browsers since mid-2020.

99% Widely available
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Android WebView Supported · Modern WebView
Full support
timeline Baseline

Bottom line: Safe for production animation timing. Pair with element.animate() and document.getAnimations().

Frequently Asked Questions

A read-only DocumentTimeline object representing the default timeline of the current document (MDN). It is used by the Web Animations API.
No. MDN marks Document.timeline as Baseline Widely available (since July 2020). It is not Deprecated, Experimental, or Non-standard.
MDN: milliseconds since Performance.timeOrigin. Before the time origin the timeline is inactive and currentTime is null.
Yes. MDN: the timeline is unique to each document and persists for the lifetime of the document, including calls to Document.open().
Element animations use a document timeline by default. document.timeline is the page’s default DocumentTimeline.
MDN: before the time origin, or when the document is inactive (for example not associated with a Window).

Next: title

Learn how to get and set the document title.

title tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful