let time; video.addEventListener('timeupdate', (event) => { time ??= video.currentTime; if ( video.currentTime - time >= 5000) { .... } });