Hello,
I want to rewrite a couple of extensions to prevent them from loading resources unless the extension is active on a page. Is there some documentation on this somewhere, or an extension that does this whose code I examine?
Thanks for any help!
On Sat, Sep 28, 2013 at 3:23 PM, Amelia Ireland amelia.ireland@gmod.orgwrote:
I want to rewrite a couple of extensions to prevent them from loading resources unless the extension is active on a page. Is there some documentation on this somewhere, or an extension that does this whose code I examine?
This is probably what you're looking for:
https://www.mediawiki.org/wiki/ResourceLoader/Developing_with_ResourceLoader...
There's a JavaScript function mw.loader.using() that loads modules before calling the passed closure.
*-- * *Tyler Romeo* Stevens Institute of Technology, Class of 2016 Major in Computer Science
Tyler Romeo <tylerromeo <at> gmail.com> writes:
On Sat, Sep 28, 2013 at 3:23 PM, Amelia Ireland <amelia.ireland <at> gmod.org>wrote:
I want to rewrite a couple of extensions to prevent them from loading resources unless the extension is active on a page. Is there some documentation on this somewhere, or an extension that does this whose code I can examine?
This is probably what you're looking for:
https://www.mediawiki.org/wiki/ResourceLoader/Developing_ with_ResourceLoader#Client-side_.28dynamically.29
There's a JavaScript function mw.loader.using() that loads modules before calling the passed closure.
I've already used this method with one of the extensions. Is there anything on the backend / PHP side so that I can advantage of ResourceLoader script compression? It seems like it should be possible, but I don't have a thorough-enough knowledge of the innards of Mediawiki, and I can't find anything in the docs on this topic.
Thanks, Amelia.
On Mon, Sep 30, 2013 at 09:27:29PM +0000, Amelia Ireland wrote:
I've already used this method with one of the extensions. Is there anything on the backend / PHP side so that I can advantage of ResourceLoader script compression? It seems like it should be possible, but I don't have a thorough-enough knowledge of the innards of Mediawiki, and I can't find anything in the docs on this topic.
As long as you know that the extension is enabled before the page loads or the user takes any actions, you can simply find out where the modules are added to the OutputPage (look/grep for "addModules") and wrap it in an appropriate if statement/block. I don't think ResourceLoader itself has any nice methods to do this for you, but I also don't think it's a particularly useful feature, given the ease with which developers can do it themselves...
wikitech-l@lists.wikimedia.org