Under the latest nightly release bindReady() first checks for
document.readyState === 'complete'.  Browsers that support the
readySTate property will then execute the jQuery.ready() function and
this case will be handled properly.  IE, Safari and Chrome all appear
to have this; however, Firefox does not and as such attaching jQuery
post-document-load will never fire the jQuery.ready() event.

This is a general problem with post-loading 3rd-party scripts.  Most
assume they are operating in a pre-load context and do things like
document.write() or register for the window.onload event.  Seems
reasonable that the document.readyState property should be part of
some kind of standard so scripts can determine what functionality is
available.  Also seems as if there should be some mechanism for
handling subscribing to a one-time event that has all ready occurred.
This is a problem with the "load" event not just on the document but
any element.  It may be unique in this sense.  I am not sure if any
other events would only fire once.  jQuery's solution is to
immediately execute functions passed to the ready() method if the
document is all ready ready which is reasonable; however, seems like a
Standard should define how this should be handled.

If jQuery is post-loaded in this manner and there is allready a
version of jQuery that was correctly loaded inline, perhaps jQuery
could use the jQuery.isReady property of the existing version in
addition to its event registration?  This might allow a page author
who loads third-party libs and knows they will both load their own
version of jQuery and subscribe to the jQuery(document).ready event to
provide the third-party version of jQuery with a little hint as to the
document's ready state.

In the interim, I am attempting to override the attachEvent and
addEventListener methods to intercept this registration.  I will
update as to whether or not this is even feasible.

Reply via email to