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>Krinkle
No edit summary
imported>Dzahn
Line 1: Line 1:
This snippets shows how to '''get the source code of a module''' from a web browser, for a module loaded on that page.
This snippet shows how to '''get the source code of a module''' from a web browser, for a module registered on that page.


<source lang="javascript">
<source lang="javascript">
Line 30: Line 30:


[[Category:Performance Team]]
[[Category:Performance Team]]
[[Category:Runbooks]]

Revision as of 09:38, 13 March 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.config.get('wgLoadScript'),
		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