Performance/Runbook/Module source

From Wikitech
Jump to navigation Jump to search

This snippet shows how to get the source code of a module from a web browser, for a module registered on that page.

function getSource( module ) {
	var version = mw.loader.getVersion( module );
	if ( !version ) {
		console.warn('Unknown module: ' + module );
		return false;
	}
	$.ajax( {
		url: mw.util.wikiScript('load'),
		dataType: 'text',
		data: {
			debug: true,
			only: 'scripts',
			modules: module,
			lang: mw.config.get('wgUserLanguage'),
			skin: mw.config.get('skin'),
			version: version,
			raw: 1
		}
	} ).then( function ( data ) {
		console.log( data );
	} );
}

External links