Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to lazy load doubleclick ads that use document.write?

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?

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.

like image 743
Joe Hanink Avatar asked Jan 02 '11 20:01

Joe Hanink


1 Answers

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

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

like image 173
Joe Hanink Avatar answered Sep 19 '22 22:09

Joe Hanink