Loading... 之前网站第一次访问,与pjax加载后js图标不显示的问题一直困扰我,昨天无意间把谷歌广告(GoogleAdsense)下面这段单元广告js删掉之后惊奇的发现网站正常了,于是就开整了。 <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> ## 前言 由于本站使用的是handsome主题,其他网站有js加载不全时,不一定是谷歌广告问题。我只是记录一下![web网站css,js更新后客户浏览器缓存问题,需要刷新才能正常展示的解决办法][1] ## 解决问题 首先谷歌单元谷歌的js是这样的 ```html <ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="密匙" data-ad-client="ca-pub-数字" data-ad-slot="数字"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> ``` 删除了那段js之后单元广告不加载了,想了许久后用了一个笨办法解决了。后文别笑 <img src="https://image.blogbig.cn/handsome/assets/img/emotion/aru/shy.png" class="emotion-aru"> 没有js基础。  把这段代码加入自定义js与pajx回调函数 <!-- 谷歌push --> ``` $(".adsbygoogle").each(function () { (adsbygoogle = window.adsbygoogle || []).push({}); }); ``` 有多少个adsbygoogle元素,就push广告单元多少次。**问:** 网站就加一段js可以吗? **答:** 试过不行,只会加载一次单元广告,而网站有两个地方设置有单元广告。 ## 后记 **推荐阅读** <div class="preview"> <div class="post-inser post box-shadow-wrap-normal"> <a href="https://www.blogbig.cn/archives/googleadsense.html" target="_blank" class="post_inser_a no-external-link no-underline-link"> <div class="inner-image bg" style="background-image: url(https://image.blogbig.cn/2020/02/29/1582959278.jpg);background-size: cover;"></div> <div class="inner-content" > <p class="inser-title">解决谷歌广告拖慢网站加载速度的问题</p> <div class="inster-summary text-muted"> 网站接入谷歌广告(Google AdSense)后,经常发现整站的加载时间长了许多。对此百度了许多方法,找到了既简... </div> </div> </a> <!-- .inner-content #####--> </div> <!-- .post-inser ####--> </div> 这样操作手机页面pjax加载后,所有页面右侧广告单元还是不显示,如果各位大佬有其他更好的办法解决请求评论告诉我,在此提前感谢咯 <img src="https://image.blogbig.cn/handsome/assets/img/emotion/aru/thumb.png" class="emotion-aru"> [1]: https://www.blogbig.cn/go/788Phsay/ [2]: https://image.blogbig.cn/2020/04/12/1586685804.png [3]: https://image.blogbig.cn/2020/04/12/1586685829.png 正文到此结束 最后修改:2022 年 07 月 10 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 0 如果觉得我的文章对你有用,请随意赞赏