Archived topic
load JS on scroll event
1 reply · Started by Mouse on May 26, 2021
Hi, there, I was doing this thing before shifting to Ezoic where I was lazy loading Adsense ads on scroll with the following code:
<script type='text/javascript'> //<![CDATA[ var la=!1;window.addEventListener("scroll",function(){(0!=document.documentElement.scrollTop&&!1===la||0!=document.body.scrollTop&&!1===la)&&(!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}(),la=!0)},!0); //]]> </script>
With this I was able to achieve 100 PSI scores on both Dekstop and Mobile.
Can same be applied for now for Ezoic ads? If not what is the way to apply load on scroll for external ad js. Is there a way?
Been searching on it for hours before coming to you.
Hi there,
sorry this is out of this support forums scope - the Theme has no responsibility for the loading of adverts.
Might be best to ask Ezoic support.