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
(Created page with "This snippets shows how to '''get the source code of a module''' from a web browser, for a module loaded on that page. <source lang="javascript"> function getSource( module )...")
 
imported>Krinkle
No edit summary
Line 28: Line 28:
== External links ==
== External links ==
* [https://lists.wikimedia.org/pipermail/wikitech-l/2013-October/072378.html <nowiki>[wikitech-l] Inspecting page performance with mw.loader.inspect()</nowiki>], Ori Livneh, October 2013
* [https://lists.wikimedia.org/pipermail/wikitech-l/2013-October/072378.html <nowiki>[wikitech-l] Inspecting page performance with mw.loader.inspect()</nowiki>], Ori Livneh, October 2013
[[Category:Performance Team]]

Revision as of 23:33, 20 December 2018

This snippets shows how to get the source code of a module from a web browser, for a module loaded 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