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
(wgLoadScript is internal)
imported>Krinkle
mNo edit summary
Line 2: Line 2:


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



Revision as of 18:23, 24 August 2021

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