Index: branches/resourceloader/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -190,6 +190,8 @@ |
191 | 191 | var jobs = []; |
192 | 192 | // Flag indicating that requests should be suspended |
193 | 193 | var suspended = true; |
| 194 | + // Flag inidicating that document ready has occured |
| 195 | + var ready = false; |
194 | 196 | |
195 | 197 | /* Private Methods */ |
196 | 198 | |
— | — | @@ -457,7 +459,7 @@ |
458 | 460 | // all before we've cleared it causing each request to include modules which are already loaded |
459 | 461 | batch = []; |
460 | 462 | // Asynchronously append a script tag to the end of the body |
461 | | - setTimeout( function() { |
| 463 | + function request() { |
462 | 464 | var html = ''; |
463 | 465 | for ( var r = 0; r < requests.length; r++ ) { |
464 | 466 | // Build out the HTML |
— | — | @@ -466,7 +468,13 @@ |
467 | 469 | } |
468 | 470 | // Append script to body |
469 | 471 | $( 'body' ).append( html ); |
470 | | - }, 0 ) |
| 472 | + } |
| 473 | + // Load asynchronously after doumument ready |
| 474 | + if ( ready ) { |
| 475 | + setTimeout( function() { request(); }, 0 ) |
| 476 | + } else { |
| 477 | + request(); |
| 478 | + } |
471 | 479 | } |
472 | 480 | }; |
473 | 481 | /** |
— | — | @@ -616,6 +624,8 @@ |
617 | 625 | suspended = false; |
618 | 626 | that.work(); |
619 | 627 | } |
| 628 | + |
| 629 | + $(document).ready( function() { ready = true; } ); |
620 | 630 | } )(); |
621 | 631 | |
622 | 632 | /* Extension points */ |