document.addEventListener("DOMContentLoaded", () => { let bodies = document.getElementsByTagName("body"); if(bodies.length === 1) { let body = bodies[0]; let xhr = new XMLHttpRequest(); xhr.onreadystatechange = () => { let video = document.createElement("video"); body.appendChild(video); let ctype = xhr.getResponseHeader("Content-Type"); let player = videojs(video); let source = {}; source.type = ctype; source.src = "{{ stream }}"; player.src(source); } xhr.open("HEAD", "{{ stream }}", true); xhr.send(); } });