youtube lazy

function lazyload_youtube_script()
{
if (is_front_page()) {
?>

document.addEventListener('DOMContentLoaded', function() { const lazyIframes = document.querySelectorAll('.lazy-youtube');</p><p> if ('IntersectionObserver' in window) { const observer = new IntersectionObserver((entries, observer) => { entries.forEach((entry) => { if (entry.isIntersecting) { const iframe = entry.target; iframe.src = iframe.dataset.src; observer.unobserve(iframe); } }); });</p><p> lazyIframes.forEach((iframe) => { observer.observe(iframe); }); } else { // Fallback for browsers that do not support Intersection Observer lazyIframes.forEach((iframe) => { iframe.src = iframe.dataset.src; }); } });

The post youtube lazy appeared first on We Said Go Travel.

 •  0 comments  •  flag
Share on Twitter
Published on November 19, 2024 01:22
No comments have been added yet.


We Said Go Travel

Lisa Niver
Lisa Niver is the founder of We Said Go Travel and author of the memoir, Traveling in Sin. She writes for USA Today, Wharton Business Magazine, the Jewish Journal and many other on and offline publica ...more
Follow Lisa Niver's blog with rss.