1function initHeroVideo() { 2 const video = document.querySelector("[data-hero-video]"); 3 if (!video) return; 4 5 const reduceMotion = window.CrownMotion?.reducedMotion || window.matchMedia("(prefers-reduced-motion: reduce)").matches; 6 const lowTier = window.CrownMotion?.tier === "low"; 7 const saveData = navigator.connection && navigator.connection.saveData; 8 const mobile = window.matchMedia("(max-width: 700px)").matches; 9 10 if (reduceMotion || lowTier || saveData || mobile) { 11 video.pause(); 12 video.removeAttribute("autoplay"); 13 video.removeAttribute("src"); 14 video.querySelectorAll("source").forEach((el) => el.remove()); 15 video.load(); 16 return; 17 } 18 19 video.play().catch(() => { 20 // Autoplay blocked; poster image remains visible. 21 }); 22 23 document.addEventListener("visibilitychange", () => { 24 if (document.hidden) { 25 video.pause(); 26 } else if (video.dataset.inView !== "false") { 27 video.play().catch(() => {}); 28 } 29 }); 30 31 if ("IntersectionObserver" in window) { 32 const observer = new IntersectionObserver( 33 (entries) => { 34 entries.forEach((entry) => { 35 video.dataset.inView = String(entry.isIntersecting); 36 if (entry.isIntersecting && !document.hidden) { 37 video.play().catch(() => {}); 38 } else { 39 video.pause(); 40 } 41 }); 42 }, 43 { threshold: 0 } 44 ); 45 observer.observe(video); 46 } 47} 48 49document.addEventListener("DOMContentLoaded", initHeroVideo);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.