Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2580,9 +2580,7 @@ |
2581 | 2581 | if ( $modules ) { |
2582 | 2582 | $scripts .= Html::inlineScript( |
2583 | 2583 | ResourceLoader::makeLoaderConditionalScript( |
2584 | | - Xml::encodeJsCall( 'mw.loader.load', array( $modules ) ) . |
2585 | | - // the go() call is unnecessary if we inserted top modules, but we don't know for sure that we did |
2586 | | - Xml::encodeJsCall( 'mw.loader.go', array() ) |
| 2584 | + Xml::encodeJsCall( 'mw.loader.load', array( $modules ) ) |
2587 | 2585 | ) |
2588 | 2586 | ); |
2589 | 2587 | } |
Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -582,8 +582,6 @@ |
583 | 583 | var queue = []; |
584 | 584 | // List of callback functions waiting for modules to be ready to be called |
585 | 585 | var jobs = []; |
586 | | - // Flag indicating that requests should be suspended |
587 | | - var suspended = true; |
588 | 586 | // Flag inidicating that document ready has occured |
589 | 587 | var ready = false; |
590 | 588 | // Marker element for adding dynamic styles |
— | — | @@ -988,88 +986,85 @@ |
989 | 987 | } |
990 | 988 | // Clean up the queue |
991 | 989 | queue = []; |
992 | | - // After document ready, handle the batch |
993 | | - if ( !suspended && batch.length ) { |
994 | | - // Always order modules alphabetically to help reduce cache |
995 | | - // misses for otherwise identical content |
996 | | - batch.sort(); |
997 | | - // Build a list of request parameters |
998 | | - var base = { |
999 | | - 'skin': mw.config.get( 'skin' ), |
1000 | | - 'lang': mw.config.get( 'wgUserLanguage' ), |
1001 | | - 'debug': mw.config.get( 'debug' ) |
1002 | | - }; |
1003 | | - // Extend request parameters with a list of modules in the batch |
1004 | | - var requests = []; |
1005 | | - // Split into groups |
1006 | | - var groups = {}; |
1007 | | - for ( var b = 0; b < batch.length; b++ ) { |
1008 | | - var group = registry[batch[b]].group; |
1009 | | - if ( !( group in groups ) ) { |
1010 | | - groups[group] = []; |
| 990 | + // Always order modules alphabetically to help reduce cache |
| 991 | + // misses for otherwise identical content |
| 992 | + batch.sort(); |
| 993 | + // Build a list of request parameters |
| 994 | + var base = { |
| 995 | + 'skin': mw.config.get( 'skin' ), |
| 996 | + 'lang': mw.config.get( 'wgUserLanguage' ), |
| 997 | + 'debug': mw.config.get( 'debug' ) |
| 998 | + }; |
| 999 | + // Extend request parameters with a list of modules in the batch |
| 1000 | + var requests = []; |
| 1001 | + // Split into groups |
| 1002 | + var groups = {}; |
| 1003 | + for ( var b = 0; b < batch.length; b++ ) { |
| 1004 | + var group = registry[batch[b]].group; |
| 1005 | + if ( !( group in groups ) ) { |
| 1006 | + groups[group] = []; |
| 1007 | + } |
| 1008 | + groups[group][groups[group].length] = batch[b]; |
| 1009 | + } |
| 1010 | + for ( var group in groups ) { |
| 1011 | + // Calculate the highest timestamp |
| 1012 | + var version = 0; |
| 1013 | + for ( var g = 0; g < groups[group].length; g++ ) { |
| 1014 | + if ( registry[groups[group][g]].version > version ) { |
| 1015 | + version = registry[groups[group][g]].version; |
1011 | 1016 | } |
1012 | | - groups[group][groups[group].length] = batch[b]; |
1013 | 1017 | } |
1014 | | - for ( var group in groups ) { |
1015 | | - // Calculate the highest timestamp |
1016 | | - var version = 0; |
1017 | | - for ( var g = 0; g < groups[group].length; g++ ) { |
1018 | | - if ( registry[groups[group][g]].version > version ) { |
1019 | | - version = registry[groups[group][g]].version; |
1020 | | - } |
| 1018 | + var reqBase = $.extend( { 'version': formatVersionNumber( version ) }, base ); |
| 1019 | + var reqBaseLength = $.param( reqBase ).length; |
| 1020 | + var reqs = []; |
| 1021 | + var limit = mw.config.get( 'wgResourceLoaderMaxQueryLength', -1 ); |
| 1022 | + // We may need to split up the request to honor the query string length limit |
| 1023 | + // So build it piece by piece |
| 1024 | + var l = reqBaseLength + 9; // '&modules='.length == 9 |
| 1025 | + var r = 0; |
| 1026 | + reqs[0] = {}; // { prefix: [ suffixes ] } |
| 1027 | + for ( var i = 0; i < groups[group].length; i++ ) { |
| 1028 | + // Determine how many bytes this module would add to the query string |
| 1029 | + var lastDotIndex = groups[group][i].lastIndexOf( '.' ); |
| 1030 | + // Note that these substr() calls work even if lastDotIndex == -1 |
| 1031 | + var prefix = groups[group][i].substr( 0, lastDotIndex ); |
| 1032 | + var suffix = groups[group][i].substr( lastDotIndex + 1 ); |
| 1033 | + var bytesAdded = prefix in reqs[r] ? |
| 1034 | + suffix.length + 3 : // '%2C'.length == 3 |
| 1035 | + groups[group][i].length + 3; // '%7C'.length == 3 |
| 1036 | + |
| 1037 | + // If the request would become too long, create a new one, |
| 1038 | + // but don't create empty requests |
| 1039 | + if ( limit > 0 && reqs[r] != {} && l + bytesAdded > limit ) { |
| 1040 | + // This request would become too long, create a new one |
| 1041 | + r++; |
| 1042 | + reqs[r] = {}; |
| 1043 | + l = reqBaseLength + 9; |
1021 | 1044 | } |
1022 | | - var reqBase = $.extend( { 'version': formatVersionNumber( version ) }, base ); |
1023 | | - var reqBaseLength = $.param( reqBase ).length; |
1024 | | - var reqs = []; |
1025 | | - var limit = mw.config.get( 'wgResourceLoaderMaxQueryLength', -1 ); |
1026 | | - // We may need to split up the request to honor the query string length limit |
1027 | | - // So build it piece by piece |
1028 | | - var l = reqBaseLength + 9; // '&modules='.length == 9 |
1029 | | - var r = 0; |
1030 | | - reqs[0] = {}; // { prefix: [ suffixes ] } |
1031 | | - for ( var i = 0; i < groups[group].length; i++ ) { |
1032 | | - // Determine how many bytes this module would add to the query string |
1033 | | - var lastDotIndex = groups[group][i].lastIndexOf( '.' ); |
1034 | | - // Note that these substr() calls work even if lastDotIndex == -1 |
1035 | | - var prefix = groups[group][i].substr( 0, lastDotIndex ); |
1036 | | - var suffix = groups[group][i].substr( lastDotIndex + 1 ); |
1037 | | - var bytesAdded = prefix in reqs[r] ? |
1038 | | - suffix.length + 3 : // '%2C'.length == 3 |
1039 | | - groups[group][i].length + 3; // '%7C'.length == 3 |
1040 | | - |
1041 | | - // If the request would become too long, create a new one, |
1042 | | - // but don't create empty requests |
1043 | | - if ( limit > 0 && reqs[r] != {} && l + bytesAdded > limit ) { |
1044 | | - // This request would become too long, create a new one |
1045 | | - r++; |
1046 | | - reqs[r] = {}; |
1047 | | - l = reqBaseLength + 9; |
1048 | | - } |
1049 | | - if ( !( prefix in reqs[r] ) ) { |
1050 | | - reqs[r][prefix] = []; |
1051 | | - } |
1052 | | - reqs[r][prefix].push( suffix ); |
1053 | | - l += bytesAdded; |
| 1045 | + if ( !( prefix in reqs[r] ) ) { |
| 1046 | + reqs[r][prefix] = []; |
1054 | 1047 | } |
1055 | | - for ( var r = 0; r < reqs.length; r++ ) { |
1056 | | - requests[requests.length] = $.extend( |
1057 | | - { 'modules': buildModulesString( reqs[r] ) }, reqBase |
1058 | | - ); |
1059 | | - } |
| 1048 | + reqs[r][prefix].push( suffix ); |
| 1049 | + l += bytesAdded; |
1060 | 1050 | } |
1061 | | - // Clear the batch - this MUST happen before we append the |
1062 | | - // script element to the body or it's possible that the script |
1063 | | - // will be locally cached, instantly load, and work the batch |
1064 | | - // again, all before we've cleared it causing each request to |
1065 | | - // include modules which are already loaded |
1066 | | - batch = []; |
1067 | | - // Asynchronously append a script tag to the end of the body |
1068 | | - for ( var r = 0; r < requests.length; r++ ) { |
1069 | | - requests[r] = sortQuery( requests[r] ); |
1070 | | - var src = mw.config.get( 'wgLoadScript' ) + '?' + $.param( requests[r] ); |
1071 | | - addScript( src ); |
| 1051 | + for ( var r = 0; r < reqs.length; r++ ) { |
| 1052 | + requests[requests.length] = $.extend( |
| 1053 | + { 'modules': buildModulesString( reqs[r] ) }, reqBase |
| 1054 | + ); |
1072 | 1055 | } |
1073 | 1056 | } |
| 1057 | + // Clear the batch - this MUST happen before we append the |
| 1058 | + // script element to the body or it's possible that the script |
| 1059 | + // will be locally cached, instantly load, and work the batch |
| 1060 | + // again, all before we've cleared it causing each request to |
| 1061 | + // include modules which are already loaded |
| 1062 | + batch = []; |
| 1063 | + // Asynchronously append a script tag to the end of the body |
| 1064 | + for ( var r = 0; r < requests.length; r++ ) { |
| 1065 | + requests[r] = sortQuery( requests[r] ); |
| 1066 | + var src = mw.config.get( 'wgLoadScript' ) + '?' + $.param( requests[r] ); |
| 1067 | + addScript( src ); |
| 1068 | + } |
1074 | 1069 | }; |
1075 | 1070 | |
1076 | 1071 | /** |
— | — | @@ -1261,14 +1256,6 @@ |
1262 | 1257 | }; |
1263 | 1258 | |
1264 | 1259 | /** |
1265 | | - * Flushes the request queue and begin executing load requests on demand |
1266 | | - */ |
1267 | | - this.go = function() { |
1268 | | - suspended = false; |
1269 | | - mw.loader.work(); |
1270 | | - }; |
1271 | | - |
1272 | | - /** |
1273 | 1260 | * Changes the state of a module |
1274 | 1261 | * |
1275 | 1262 | * @param module string module name or object of module name/state pairs |