You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

Performance/Runbook/Module source: Difference between revisions

From Wikitech-static
Jump to navigation Jump to search
imported>Dzahn
imported>Krinkle
(wgLoadScript is internal)
Line 9: Line 9:
}
}
$.ajax( {
$.ajax( {
url: mw.config.get('wgLoadScript'),
url: mw.util.wikiScript('load'),
dataType: 'text',
dataType: 'text',
data: {
data: {

Revision as of 22:18, 2 July 2019

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