* Defines the ResourceLoader modules that should be added to the skin
* It is recommended that skins wishing to override call parent::getDefaultModules()
* and substitute out any modules they wish to change by using a key to look them up
+ *
+ * For style modules, use setupSkinUserCss() instead.
+ *
* @return array Array of modules with helper keys for easy overriding
*/
public function getDefaultModules() {
'user' => [],
];
+ // Preload jquery.tablesorter for mediawiki.page.ready
+ if ( strpos( $out->getHTML(), 'sortable' ) !== false ) {
+ $modules['content'][] = 'jquery.tablesorter';
+ }
+
// Add various resources if required
if ( $wgUseAjax && $wgEnableAPI ) {
if ( $wgEnableWriteAPI && $user->isLoggedIn()
}
mw.hook( 'wikipage.content' ).add( function ( $content ) {
- var $sortableTables;
+ var $sortable;
// Run jquery.placeholder polyfill if placeholder is not supported
if ( !supportsPlaceholder ) {
// Run jquery.makeCollapsible
$content.find( '.mw-collapsible' ).makeCollapsible();
- // Lazy load jquery.tablesorter
- $sortableTables = $content.find( 'table.sortable' );
- if ( $sortableTables.length ) {
+ $sortable = $content.find( 'table.sortable' );
+ if ( $sortable.length ) {
+ // Preloaded by Skin::getDefaultModules()
mw.loader.using( 'jquery.tablesorter', function () {
- $sortableTables.tablesorter();
+ $sortable.tablesorter();
} );
}