Page MenuHomePhabricator

Allow to request modules by CSS classes in content
Open, LowPublic


It would be nice to allow to load specified ResourceLoader modules by adding a CSS class in content. On server side the content gets parsed for special CSS classed and adds the corresponding modules to the list modules. Modules offer a list of CSS classes which are trigger for loading of this modules.

Example use-cases:

Currently some modules get loaded by searching for CSS classes with JavaScript. See or MediaWiki:Common.js of some projects. Parsing on server side is a performance improvement because the modules can delivered with the other modules while loading. For pure CSS modules this would be an improvement because they can loaded on browser with disabled JavaScript. This feature is an enabler for cleaning the legacy shared.css.

Event Timeline

Fomafix raised the priority of this task from to Low.
Fomafix updated the task description. (Show Details)
Fomafix added a subscriber: Fomafix.

mediawiki.ui.button currently (and only temporarily) uses a simple string search on server side over the whole HTML for the class it provides: SkinTemplate.php, line 65, which actually works good enough in most cases, though it feels a little bit like a hack for me.

Maybe this check can generalized to arbitrary CSS classes and a mapping to modules.