Compact language links: Delay loading of jquery.uls module

Load jquery.uls only when the trigger is clicked.
Reduces the initial footprint by 63.9 KB (uncompressed)

Bug: T135210
Change-Id: I972cb6ea1794485917ea530f7abe68bdddc2014f
This commit is contained in:
Santhosh Thottingal
2016-05-17 11:40:15 +05:30
parent a5034fa95f
commit cbb46f7451
2 changed files with 6 additions and 4 deletions

View File

@@ -242,7 +242,6 @@
"styles": "css/ext.uls.compactlinks.less", "styles": "css/ext.uls.compactlinks.less",
"dependencies": [ "dependencies": [
"es5-shim", "es5-shim",
"jquery.uls.compact",
"mediawiki.language", "mediawiki.language",
"mediawiki.ui.button" "mediawiki.ui.button"
], ],

View File

@@ -69,7 +69,7 @@
return; return;
} }
mw.loader.using( 'ext.uls.mediawiki' ).done( function () { mw.loader.using( 'ext.uls.init' ).done( function () {
// If we're only a bit beyond max, limit to 7 instead of 9. // If we're only a bit beyond max, limit to 7 instead of 9.
// FIXME: This assumes the max is 9. // FIXME: This assumes the max is 9.
self.compactSize = ( self.listSize <= 12 ) ? 7 : max; self.compactSize = ( self.listSize <= 12 ) ? 7 : max;
@@ -187,9 +187,12 @@
var self = this; var self = this;
this.$trigger.one( 'click', function () { this.$trigger.one( 'click', function () {
// Load the ULS now.
mw.loader.using( 'ext.uls.mediawiki' ).done( function () {
self.createSelector( self.$trigger ); self.createSelector( self.$trigger );
self.$trigger.click(); self.$trigger.click();
} ); } );
} );
}, },
/** /**