1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00

Run ads only when container is visible

This commit is contained in:
Daniel 2022-02-09 13:13:05 -03:00
parent e3106cae59
commit 32d6922a68

View file

@ -2239,7 +2239,12 @@ function downloadURLOrAlertError(jsonURL, data, filename) {
function startGoogleAd(selector){
if(isVisibleAndInViewport(selector)){
console.log('startGoogleAd',selector);
(adsbygoogle = window.adsbygoogle || []).push({});
try {
(adsbygoogle = window.adsbygoogle || []).push({});
} catch (e) {
console.log('startGoogleAd ERROR',selector);
}
}else{
setTimeout(function(){startGoogleAd(selector);},1000);
}