异步谷歌的广告与同步 [英] Asynchronous google ads versus Synchronous

查看:214
本文介绍了异步谷歌的广告与同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用谷歌的DFP。

如果我使用谷歌同步的广告,我的网站载入缓慢,因为它需要在加载网页的同时加载广告,如​​果广告需要很长的回应,那么页面的加载被暂停。

If I use synchronous ads from google, my site loads slowly as it needs to load the ad at the same time it loads the website, and if an ad takes long to respond, then the load of the page gets paused.

如果我使用异步广告,这不是一个问题,因为该页面将加载羯羊或没有广告的加载。换句话说,它使网站加载速度更快。事实是,使用异步广告创建了固定的宽度和高度的div无论是否有广告显示或不。所以平时这造成我的网站上有很多空白,因为不是所有的广告位正在使用。同样还有同步的广告。

If I use asynchronous ads, this is not a problem since the page will load wether or not ads are loaded. In other words, it makes the site load faster. The thing is, using asynchronous ads creates a div with fixed width and height no matter if there are ads displaying or not. So usually this creates a lot of blank space on my site, since not all ads position are being used. Same goes with synchronous ads.

谷歌提供不创建一个div第三个选择,它只是使用JavaScript来显示广告,而如果没有在那个空间的任何广告发布,那么它只是不显示任何空白的空间,这是不错,但它的行为同步...

Google offers a third choice that doesn't create a div, it just uses javascript to display ads, and if there aren't any ads publishing in that space, then it just doesn't display any blank space, which is good, however it behaves synchronously...

我要的是使用异步广告,并没有得到空格的情况下,没有广告发布一些方法。

What I want is some method to use asynchronous ads and not get blank spaces in case no ad is publishing.

感谢。

推荐答案

我想你要找的是什么

googletag.pubads().collapseEmptyDivs();

在没有广告的展示,将隐藏空的div。此行之前调用它:

That will hide the empty divs when there are no ads to show. Call it before this line:

googletag.enableServices();

更多的文档在这里,以供参考:
<一href=\"http://support.google.com/dfp_$p$pmium/bin/answer.py?hl=en&answer=1650154\">http://support.google.com/dfp_$p$pmium/bin/answer.py?hl=en&answer=1650154

这篇关于异步谷歌的广告与同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆