It wouldn't matter if document.ready did fire before all <script> tags are
loaded, because it wouldn't affect the case you were talking about:

    <script type="text/javascript" src="jquery.js">
    </script>

    ... Imagine that document.ready somehow "fires" here...

    <script type="text/javascript" src="other.js">
    </script>

    <script type="text/javascript">
        // This code will not run until after other.js is loaded
        $(document).ready( function() {
            // This code will not run until after other.js is loaded
        });
    </script>

If document.ready were to fire before other.js and the last script tag are
loaded, it doesn't mean that JavaScript would somehow reach into the last
script tag and call its ready function. That function doesn't even exist at
that point in time.

All that would happen is that when JavaScript finally gets to the
document.ready call in the last script tag, it would run the code inside the
function immediately - at the time this script tag is loaded, which comes
after all the other scripts.

All that said, this has nothing to do with the real problem you ran into,
which you explained in a later message. I'm just going over this to help
clear up any misconceptions about document.ready.

-Mike

> From: Veeru
> 
> Hi michael,
>  i understand the <script> tags are loaded in order, but i 
> was wondering if there is a chance that document.ready is 
> fired even before all the script tags have loaded. According 
> to the documentation document.ready fires once the DOM is 
> ready, but js is not part of the DOM or is it? So if the DOM 
> is ready and the js is not ready yet, what should be done?
> 
> Thanks
> Vru
> 

Reply via email to