Skip to main content

Bug Tracker

Side navigation

#3619 closed enhancement (wontfix)

Opened November 17, 2008 04:46PM UTC

Closed November 17, 2008 04:59PM UTC

Last modified November 17, 2008 05:08PM UTC

$(document).ready waits for external js so everything waits for ads

Reported by: Owned by: flesler
Priority: minor Milestone: 1.3
Component: event Version: 1.2.6
Keywords: Cc:
Blocked by: Blocking:

Ad distributors commonly provide js tags, that use document.write to inject new <script> tags, that inject new <script> tags and so on until finally some actual html is inserted. All these scripts use document.write() and are fully under control of the ad deliverer.

With $(document).ready waiting for all html to be parsed and the DOM build, everything waits for the whole chain loaded, which can be quite some time. Wrapping the tags in $(document).ready handlers makes things even worse: The document.write() is done in the global context and so overwrites the whole DOM. This results in only the ads shown.

This is a showstopper for using $(document).ready together with software like Openads or Companies like e.g. Adlink, Doubleclick and the like.

Possible remedy (?): Allow .ready() on subparts of the DOM, not only on $(document) in a way so that only completion of that subtree is waited for.

to be used like:


<div id='site'> ... </div>

<div id='ads'> ... </div>


$('#site').ready(function(){ ... });

Attachments (0)
Change History (3)

Changed November 17, 2008 04:59PM UTC by flesler comment:1

component: unfilledevent
priority: blockerminor
resolution: → wontfix
status: newclosed

For that, you can use the elementReady plugin.

Changed November 17, 2008 05:03PM UTC by comment:2

This seems to be Gecko specific behaviour:

"If a document exists in the target, this method [] clears it [...] Also, an automatic call happens when document.write() is called after the page has loaded, but that's not defined in the W3C specification."


Changed November 17, 2008 05:08PM UTC by comment:3

Replying to [comment:1 flesler]:

Oh, Great! Wasn't aware of that one. thx.