r72170 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72169‎ | r72170 | r72171 >
Date:22:33, 1 September 2010
Author:tparscal
Status:ok
Tags:
Comment:
Only load asynchronously after document ready has occured.
Modified paths:
  • /branches/resourceloader/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/resources/mediawiki/mediawiki.js
@@ -190,6 +190,8 @@
191191 var jobs = [];
192192 // Flag indicating that requests should be suspended
193193 var suspended = true;
 194+ // Flag inidicating that document ready has occured
 195+ var ready = false;
194196
195197 /* Private Methods */
196198
@@ -457,7 +459,7 @@
458460 // all before we've cleared it causing each request to include modules which are already loaded
459461 batch = [];
460462 // Asynchronously append a script tag to the end of the body
461 - setTimeout( function() {
 463+ function request() {
462464 var html = '';
463465 for ( var r = 0; r < requests.length; r++ ) {
464466 // Build out the HTML
@@ -466,7 +468,13 @@
467469 }
468470 // Append script to body
469471 $( '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+ }
471479 }
472480 };
473481 /**
@@ -616,6 +624,8 @@
617625 suspended = false;
618626 that.work();
619627 }
 628+
 629+ $(document).ready( function() { ready = true; } );
620630 } )();
621631
622632 /* Extension points */

Status & tagging log