This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The length read-only property of the TextTrackCueList interface returns the number of cues in the list.
An unsigned long which is the number of cues in the list.
The TextTrack.cues property returns a TextTrackCueList containing the current cues for that particular track. Calling cues.length returns the number of cues in the list. Using the WebVTT track below, the value of length is 5.
WEBVTT first 00:00:00.000 --> 00:00:00.999 line:80% Hildy! second 00:00:01.000 --> 00:00:01.499 line:80% How are you? third 00:00:01.500 --> 00:00:02.999 line:80% Tell me, is the ruler of the universe in? fourth 00:00:03.000 --> 00:00:04.299 line:80% Yes, they're in - in a bad humor fifth 00:00:04.300 --> 00:00:06.000 line:80% Somebody must've stolen the crown jewels
const video = document.getElementById("video");
video.onplay = () => {
console.log(video.textTracks[0].cues.length); // 5
};
| Specification |
|---|
| HTML> # dom-texttrackcuelist-length> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
length |
23 | 12 | 31 | ≤12.1 | 6 | 25 | 31 | ≤12.1 | 6 | 1.5 | 4.4 | 6 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCueList/length