延迟加载使用document.write的双击广告的最佳方法是什么? [英] What is the best way to lazy load doubleclick ads that use document.write?

查看:257
本文介绍了延迟加载使用document.write的双击广告的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过双击请求的广告通常从广告提供商网络获得,该网络返回javascript,后者又执行document.write以在页面中放置广告。 document.write的使用要求文档处于打开状态,这意味着页面尚未到达document.complete。这会妨碍延迟或延迟加载广告内容。将这些代码放在页面底部是有帮助的,但是不足以降低所有重要的页面加载时间。 友好的iframe是我们最好的吗?有没有其他替代方法,比如覆盖document.write的聪明方法,它保留了dom中的正确位置?

Ads requested via doubleclick often get served from an ad provider network that returns javascript that in turn performs document.write to place ads in the page. The use of document.write requires that the document be open, implying that the page hasn't reached document.complete. This gets in the way of deferring or lazy loading ad content. Putting such code at page bottom is helpful but doesn't do enough to lower all-important "page-loaded" time. Are "friendly iframes" the best we have? Is there any other alternative such as a clever way to override document.write that preserves the proper place in the dom?

第三方广告使用document.write添加脚本和将内容放入页面中的当前位置。页面所有者无法控制广告脚本,也无法指定显示目标div。广告脚本需要在调用它的文档位置进行编写和渲染,因此使用延迟动态脚本加载正确定位广告并不明显。将脚本延迟加载到上下文中非常简单,但是通过document.write实现的第三方内容并不容易实现。

Third party ads use document.write to add script and content into the "current" location in a page. The page owner doesn't have control over ad scripts and can't specify a display target div. The ad script expects to write and render at the document position where it is called, so it's not obvious how to position the ad correctly using deferred dynamic script loading. Lazy loading script into context is straightforward, but third-party content rendered in place via document.write is not so easily achieved.

推荐答案

krux发布的postscribe.js,如HTML5开发大会所示。

postscribe.js by krux, as demonstrated at the HTML5 Dev Conference.

http://krux.github.com/postscribe/doc/postscribe.html
https://npmjs.org/package/postscribe

http://krux.github.com/postscribe/doc/postscribe.html https://npmjs.org/package/postscribe

这篇关于延迟加载使用document.write的双击广告的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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