Skip to main content

Bug Tracker

Side navigation

#152 closed bug (fixed)

Opened August 29, 2006 10:38AM UTC

Closed August 31, 2006 05:21AM UTC

Last modified March 15, 2012 05:16PM UTC

Events module leaves stray script element in IE

Reported by: henrah Owned by:
Priority: minor Milestone: 1.0
Component: event Version: 1.0
Keywords: Cc:
Blocked by: Blocking:

Matthias Miller's DOMReady hack creates a new script element using document.write(). After its onload event has fired, however, this element remains part of the DOM -- it will be discovered by $('script') or $('head>*'), for example.

Since this is a permanent modification of the DOM, scripts which rely on a particular order or number of elements will throw exceptions. Assumptions about the generated DOM are often unreliable anyway, but it is not hard to imagine a situation where scripts could be broken by this.

The bug is trivial to fix, however: the element just needs to delete itself once it has become unnecessary.

We can change this section:

script.onreadystatechange = function() {

if ( this.readyState == "complete" )


}; this:

script.onreadystatechange = function() {

if ( this.readyState != "complete" ) return;




...and then the problem is solved.

Attachments (0)
Change History (1)

Changed August 31, 2006 05:21AM UTC by john comment:1

resolution: → fixed
status: newclosed

Fixed in SVN rev 245.