It'd be nice for extensions to register from a hook so they don't cause ResourceLoader.php and Resources.php to be loaded on every single request.
Version: 1.17.x
Severity: enhancement
It'd be nice for extensions to register from a hook so they don't cause ResourceLoader.php and Resources.php to be loaded on every single request.
Version: 1.17.x
Severity: enhancement
Something like...
// Allow extensions to register modules
wfRunHooks( 'ResourceLoaderBeforeRespond', $context );
...inside of ResourceLoader::respond().
(In reply to comment #1)
Something like...
// Allow extensions to register modules
wfRunHooks( 'ResourceLoaderBeforeRespond', $context );
Pretty much yeah, except the second parameter is an array of parameters.
...inside of ResourceLoader::respond().
Because there are more ResourceLoader:: functions that use registrations, I'd prefer having a function called by all such entry points that then calls this hook once and only once.
In practical terms, something like
protected static function getHookRegistrations( $context ) {
static $done = false; wfRunHooks( 'ResourceLoaderRegistrations', array( $context ) ); $done = true;
}
Then in all functions using the registration data (including respond(), but also other functions reading from self::$modules), call this function.
This has been done for a while now. The hook is called ResourceLoaderRegisterModules.