$(document).ready vs window.onload vs window.addEventListener : <p>I had been researching on the above 3 JS/jQuery commands and I want to execute the JavaScript after EVERYTHING is loaded, but seems all the above 3 scripts are fired before the DIV is loaded. Can anyone tell me how to execute a JS script after EVERYTHING is loaded. Please see the following html : If you carefully notice this, you will see the alert pop up window before the DIV is loaded. I am running it in Chrome. </p>

<pre><code>      &lt;script&gt;

    window.addEventListener( 'load', function( event ) {
            alert("test");
    }); 


    $(document).ready(function(){
            alert("test"); 
    });


    window.onload = function(e){ 
            alert("test"); 
    }

      &lt;/script&gt; 

   &lt;body&gt;
    &lt;div&gt;
        Hello There!!!
    &lt;/div&gt;

   &lt;/body&gt;
</code></pre>
