1(function () { 2 'use strict'; 3 4 const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)'); 5 const saveData = Boolean(navigator.connection && navigator.connection.saveData); 6 7 function hydrate(video) { 8 const source = video.querySelector('source[data-src]'); 9 if (source && !source.src) { 10 source.src = source.dataset.src; 11 video.load(); 12 } 13 } 14 15 const observer = new IntersectionObserver(function (entries) { 16 entries.forEach(function (entry) { 17 const video = entry.target; 18 if (entry.isIntersecting) { 19 hydrate(video); 20 if (!reducedMotion.matches && !saveData) { 21 video.play().catch(function () {}); 22 } 23 } else { 24 video.pause(); 25 } 26 }); 27 }, { rootMargin: '200px 0px', threshold: 0.05 }); 28 29 function observe(root) { 30 if (root.matches && root.matches('video[data-viewport-video]')) observer.observe(root); 31 root.querySelectorAll && root.querySelectorAll('video[data-viewport-video]').forEach(function (video) { 32 observer.observe(video); 33 }); 34 } 35 36 window.observeViewportVideos = observe; 37 document.addEventListener('DOMContentLoaded', function () { 38 observe(document); 39 new MutationObserver(function (mutations) { 40 mutations.forEach(function (mutation) { 41 mutation.addedNodes.forEach(function (node) { 42 if (node.nodeType === 1) observe(node); 43 }); 44 }); 45 }).observe(document.body, { childList: true, subtree: true }); 46 }); 47}());
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.