Efficient way to detect window.load in this case
<p>My requirement is, I have to execute a script after all the page scripts execution is done. I am using the below code to do the same  </p>

<pre><code>$(window).load(function ()
{
  var j = setTimeout (function ()
  {
     alert("All page scripts have been executed and DOM is ready.");
     // And here the script will work 
        to update the DOM changes made by the pagescripts.
  },100); // Here execution time cant be less than 100 all the time, right?
});
</code></pre>

<p>But the problem is, In the above case I have used time 100. But sometimes the page is being loaded in 101 milliseconds. In such cases the script is failed to update the changes.
Lets see an example for this  </p>

<p>There is a page script which will add images to the DOM when DOM is ready. And if I use </p>

<pre><code>$(document).ready()   
</code></pre>

<p>the script is failed to detect images as the images are not yet added to the DOM.</p>

<p>Please let me know if you need some more clarification on Question.</p>
