You can wait here with on document loaded - there is certainly also more elegant way.
function yourFunction () {
console.log("document loaded");
}
(document.readyState != 'complete') ? document.addEventListener('DOMContentLoaded', function() { yourFunction() }) : yourFunction();
You'll probably do something like this:
function addSourceToVideo(element, src, type) {
var source = document.createElement('source');
source.src=src;
source.type = type;
element.appendChild(source);
}
var video = document.createElement('video');
document.body.appendChild(video);
addSourceToVideo(video, '<YOUR_VIDEO_URL>.mp4', 'video/mp4');
video.play(); // Hope you do it differently - because that doesn't work nowadays, because e.g. Google doesn't allow this anymore because of autoplay - and you get an error towards something like this "..failed because the user didn't interact with the document first."
Hope this helps you a bit.
..and no, I don't have a blog yet. But you can follow me here.