It's pretty easy for your script to load AFTER the video, if the video is cached. That can make listening to these events unreliable. I resolved this race condition like so:
(() => { const video = $('#video'); const onVideoLoaded = () => { ... }; if (video[0].duration > 0) onVideoLoaded(); else video.on('loadedmetadata', onVideoLoaded);})();
This will at least get you to solid ground - if the video loads, your method will always fire exactly once - whether the video loads before the script, or the script before the video. Attaching to the event naively is going to get you code that mysteriously does nothing on cached visits.