9

所以我们在我们的网站上投放谷歌广告。

我开始思考,每个广告块(各种尺寸)都会加载..

<script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

例如:

<script type="text/javascript"><!--
            google_ad_client = "ca-pub-xxxxxxxxxxxxxx";
            /* ad served */
            google_ad_slot = "xxxxxxxxx";
            google_ad_width = 728;
            google_ad_height = 90;
            //-->
            </script>
            <script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>

和其他广告,不同的插槽( id's )amd 尺寸,在同一页面上也加载:

http://pagead2.googlesyndication.com/pagead/show_ads.js

每一次。因此,一个带有三个广告的页面会加载完全相同的 js 文件 3 次..

删除该脚本文件,将其一次添加到头部,对我们不起作用.. 广告只是不显示。

那么有没有一种方法可以只加载一次 show_ads.js 文件/页面加载?

4

1 回答 1

15

Google 广告脚本使用document.write(),这意味着该脚本必须位于您想要广告的 HTML 中的位置。

但是,不要担心:show_ads.js文件只会被您的浏览器下载一次。随后<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js">的 s 将从缓存中加载。

事实上,标题告诉您的浏览器它可以直接从缓存中加载文件下一小时,因此无论查看多少页面,每个会话Cache-Control都应该只访问一次pagead2.googlesyndication.com 。

于 2012-06-01T00:01:55.610 回答