Wikimedia Developer Support

How to see why a RL module is loaded

resourceloader

#1

Is there an easy way to see why a module is being loaded as a dependecy? So for example module “X” is never loaded by OutputPage:addModules / OutputPage:addModuleScripts or mw.loader.using (or similar). But still it is loaded on every page request. Therefore some other module must require it as a dependency.
Are there any debug logs/tools that could help me to find such a dependency?


#2

You could fetch the dependency tree and do some kind of pathfinding on it. I’m not aware of a better way.


#3

Thanks.

I found executing

for ( module in mw.loader.moduleRegistry ) {
	if( mw.loader.moduleRegistry[module].dependencies.indexOf( 'X' ) !== -1) {
		var state = mw.loader.getState( module );
		if( state === 'ready' ) {
			console.log( module );
		}
	}
}

in the JavaScript console to be helpfull.