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

Performance/Runbook/Module source

From Wikitech-static
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.

mw.loader._getSource = function ( module ) {
	if ( !mw.loader.getState( module ) ) {
		console.warn( 'Unknown module: ' + module );
		return false;
	}
	var path = mw.util.wikiScript('load') + '?' + $.param({
		debug: true,
		only: 'scripts',
		modules: module,
		lang: mw.config.get('wgUserLanguage'),
		skin: mw.config.get('skin'),
		raw: 1
	});
	console.log( new URL( path, location ).href );
	$.ajax( { url: path, dataType: 'text' } ).then( function ( data ) {
		console.log( data );
	} );
};

External links