r73424 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73423‎ | r73424 | r73425 >
Date:23:32, 20 September 2010
Author:tparscal
Status:ok
Tags:
Comment:
Implemented request grouping on the client.
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -502,16 +502,27 @@
503503 );
504504 }
505505 } else {
506 - // Calculate the highest timestamp
507 - var version = 0;
 506+ // Split into groups
 507+ var groups = {};
508508 for ( var b = 0; b < batch.length; b++ ) {
509 - if ( registry[batch[b]].version > version ) {
510 - version = registry[batch[b]].version;
 509+ var group = registry[batch[b]].group;
 510+ if ( !( group in groups ) ) {
 511+ groups[group] = [];
511512 }
 513+ groups[group][groups[group].length] = batch[b];
512514 }
513 - requests[requests.length] = $.extend(
514 - { 'modules': batch.join( '|' ), 'version': formatVersionNumber( version ) }, base
515 - );
 515+ for ( var group in groups ) {
 516+ // Calculate the highest timestamp
 517+ var version = 0;
 518+ for ( var g = 0; g < groups[group].length; g++ ) {
 519+ if ( registry[groups[group][g]].version > version ) {
 520+ version = registry[groups[group][g]].version;
 521+ }
 522+ }
 523+ requests[requests.length] = $.extend(
 524+ { 'modules': groups[group].join( '|' ), 'version': formatVersionNumber( version ) }, base
 525+ );
 526+ }
516527 }
517528 // Clear the batch - this MUST happen before we append the script element to the body or it's
518529 // possible that the script will be locally cached, instantly load, and work the batch again,

Status & tagging log