> But that's the issue, It's way way waaay too late at this point, as
> the document was "ready" (and fired that event) once the HTML was sent
> to the browser and ready for DOM manipulation, which was forever ago
> at this point (right from the docs: "Binds a function to be executed
> whenever the DOM is ready to be traversed and manipulated")

I disagree. First off, see this example which works perfectly:

http://www.damagedsoftware.com/earlyjqueryready_test.html

In the case that the dom is ready when a ready listener is added
jQuery will execute the listener immediately. See the following code
from jQuery which has a test for this case:

        ready: function(fn) {
                // Attach the listeners
                bindReady();

                // If the DOM is already ready
                if ( jQuery.isReady )
                        // Execute the function immediately
                        fn.call( document, jQuery );

                // Otherwise, remember the function for later
                else
                        // Add the function to the wait list
                        jQuery.readyList.push( fn );

                return this;
        },

> there is nothing gained by that method, although i would be curious as
> to what you think they may be

I tried to explain what was to be gained in my previous email sorry it
was not clear. See the following example:
http://www.damagedsoftware.com/jqueryready_test.html

In this case it is entirely possible that jqueryHasLoaded() will be
called before the dom is ready for manipulation which is why any dom
manipulation code should be attached to a ready event regardless of
how jQuery is loaded.

There are many scripts that rely on the immediate execution of their
ready listeners if the document is ready when the listener is added.
In my opinion these scripts should not break just because jQuery was
loaded after the page became ready.

Ryan


Reply via email to