Alex Rivera | Logout

JQuery is waiting for images to load before executing document.ready

Asked 2009-01-25T10:11:26.027
48

Update: This bug has been confirmed by at least two others. Even if you dont read my full post - if you're reading this and using JQuery 1.3.1 then stop using it if you're relying on any handlers that you want to execute when the DOM is complete but before the page's images have loaded.

Update2: Thanks to Tom (user id 20!) for posting the link to the ticket on the jQuery bug tracker.

Update3 - 2009/01/28: The issue has been properly resolved (for those for whom reverting to 1.2.6 is not an option). For anyone currently using 1.3.1 and needing an immediate fix you can read the accepted answer below for direction. Thanks John.


I just upgraded to JQuery 1.3.1, and it took me several hours to realize that my beloved

$(function( ) {  ... }

syntax was now waiting for the entire page to load (including images) before executing the function body. I was seeing strange behavior when trying to integrate Yahoo's menus. (Fortunately I had some slow loading images on my page which made me aware of the problem)!

I made a test file becasue I figured something more complex was going on, but I still had the same symptoms even with this simple file.

<head>
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>   
   <script>
    $(function() {    
      alert("Ready"); 
    });
  </script>
</head>

<body>      
  <img src="<PATH_TO_DYNAMIC_IMAGE>_1.jpg" />
  <img src="<PATH_TO_DYNAMIC_IMAGE>_2.jpg" />
  <img src="<PATH_TO_DYNAMIC_IMAGE>_3.jpg" />
  <img src="<PATH_TO_DYNAMIC_IMAGE>_4.jpg" />       
&
Edit
Report

1 Answer

3

yes i've added an example, its clearly a bug in IE6 & 7 (i havn't tested it in other IE versions). It seems as if the 1.3.1 Version has a lot of bugs. :(

Here is the example link: http://www.kollermedia.at/jquery_bug.html

answered 2009-01-27T10:10:41.387

Your Answer