Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 11 years ago

#152 closed bug (fixed)

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" )



...to this: script.onreadystatechange = function() {

if ( this.readyState != "complete" ) return; this.parentNode.removeChild(this); jQuery.ready();


...and then the problem is solved.

Change History (1)

comment:1 Changed 16 years ago by john

Resolution: fixed
Status: newclosed

Fixed in SVN rev 245.

Note: See TracTickets for help on using tickets.