diff --git a/html/poketube.ejs b/html/poketube.ejs index 91d214c0..c7bbc311 100644 --- a/html/poketube.ejs +++ b/html/poketube.ejs @@ -1621,6 +1621,21 @@ if (/[?&]autoplay=/.test(location.search)) { } } +const lazyElements = document.querySelectorAll('*'); + +const observer = new IntersectionObserver((entries, observer) => { + entries.forEach(entry => { + if (entry.isIntersecting) { + entry.target.classList.add('loaded'); + observer.unobserve(entry.target); + } + }); +}); + +lazyElements.forEach(element => { + observer.observe(element); +}); + // Function to refresh the page const refreshPage = () => { location.reload();