加快网站显示速度,Adsense延迟加载代码

1、删除所有谷歌广告,脚本标记代码

(包括其它自动广告、手动广告)

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5720871895974674" crossorigin="anonymous"></script>

<ins 
class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-5720871895974674"
data-ad-slot="9767376557"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

2、添加 Adsense LazyLoad 代码

<script>
var lazyloadads = false;
window.addEventListener("scroll", function() {
if ((document.documentElement.scrollTop != 0 && lazyloadads === false) || (document.body.scrollTop != 0 && lazyloadads === false)) {

(function() {
var ad = document.createElement('script');
ad.type = 'text/javascript';
ad.async = true;
ad.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
var sc = document.getElementsByTagName('script')[0];
sc.parentNode.insertBefore(ad, sc);
})();

lazyloadads = true;
}
}, true)
</script>

<ins 
class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-5720871895974674"
data-ad-slot="9767376557"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

互联网

2021-11-27

前一篇|Previous:
后一篇|Next:

相关文章|Related Posts

  • 顶级国际域名证书
  • 怎样删除微信里的单向“好友”?
  • WordPress:下拉“分类”菜单
  • 微信朋友圈,发表文字,如何完整显示?
  • 加快网站显示速度,Adsense延迟加载代码