Right now I am seeing 30-40 KB increase (depending on the wiki) when I enable compact language links before user even opens more languages menu.
The module itself is small, 7 KB uncompressed but it pulls in some heavy dependencies such as:
1 "jquery.uls.data" "35.7 KiB" 36548 2 "jquery.uls" "33.5 KiB" 34264 3 "jquery.i18n" "30.4 KiB" 31125 22 "ext.uls.languagenames" "7.4 KiB" 7614 24 "ext.uls.compactlinks" "7.2 KiB" 7367 25 "mediawiki.libs.pluralruleparser" "6.8 KiB" 6971 34 "ext.uls.messages" "4.9 KiB" 4971
Of these actually only jquery.uls.data, mediawiki.libs.pluralruleparser and of course ext.uls.compactlinks is needed. With some simple changes we seem to be able to bring the initial footprint increase down to 2 KB:
diff --git a/resources/js/ext.uls.compactlinks.js b/resources/js/ext.uls.compactlinks.js index 5a5ee35..0669a4c 100644 --- a/resources/js/ext.uls.compactlinks.js +++ b/resources/js/ext.uls.compactlinks.js @@ -69,7 +69,7 @@ return; } - mw.loader.using( 'ext.uls.mediawiki' ).done( function () { + mw.loader.using( [ 'ext.uls.init', 'jquery.uls.data' ] ).done( function () { // If we're only a bit beyond max, limit to 7 instead of 9. // FIXME: This assumes the max is 9. self.compactSize = ( self.listSize <= 12 ) ? 7 : max;
This patch doesn't work as is, some code in ext.uls.init uses $.uls.data without depending on jquery.uls.data and $.fn.uls.defaults.languages without depending on jquery.uls (but I'd rather it not to depend on jquery.uls). Also I think this code from ext.uls.mediawiki should be moved to something else, perhaps directly to jquery.uls.data module:
$.uls.data.addLanguage( 'als', { target: 'gsw' } );