(function(){ var isMobile=window.matchMedia && window.matchMedia('(max-width:900px)').matches; if(!isMobile)return; /* iOS Safari can become unstable when several off-screen looping videos and composited blur layers stay active at once. Keep only visible videos playing. */ var videos=Array.prototype.slice.call(document.querySelectorAll('video')); if('IntersectionObserver' in window && videos.length){ var mediaObserver=new IntersectionObserver(function(entries){ entries.forEach(function(entry){ var v=entry.target; if(entry.isIntersecting){ if(v.hasAttribute('autoplay')){ var p=v.play(); if(p&&p.catch)p.catch(function(){}); } }else{ try{v.pause();}catch(e){} } }); },{rootMargin:'120px 0px',threshold:0.01}); videos.forEach(function(v){ mediaObserver.observe(v); }); } document.addEventListener('visibilitychange',function(){ if(document.hidden){ videos.forEach(function(v){try{v.pause();}catch(e){}}); } },{passive:true}); })(); html>