Talk:ResourceLoader/Migration guide for extension developers/LQT Archive 1

Getting started
I'm trying to make an extension compatible with the ResourceLoader. All I have is one .js file to include. Here's what I have so far - (pastebin). Registration seems to work, my page source has:  but the javascript functions aren't being loaded. Firefox error console clearly states the function is not defined. What am I missing? --MrC 22:06, 12 October 2010 (UTC)


 * You are probably operating under the assumption that your code is being run in the global scope. ResourceLoader encapsulates code in closures which are executed as soon as all of their dependencies are met, meaning that all of the functions and variables you created are only defined within the scope of the closure. If you want to export functions or variables to the global scope, just use  or   You will be able to refer to them as you normally would from there on out. I will note however that polluting the global scope is tempting, but you should seriously consider wither making your code a jQuery plug-in or following the model of mediaWiki and jQuery objects, in which your entire library is encapsulated in a single object. --Trevor Parscal 00:09, 13 October 2010 (UTC)


 * Ok, thanks, that makes sense. Where would the calls to window.myMethod go?  I would certainly like to use the MW model, but so far I can find very little documentation on why/when/how to do it.  I'm still not sure if I should even be using ResourceLoader.  Here's my situation- I have a parser extension that converts my custom tag into some code which makes calls to myExt.js, which is short and only serves this one tag.  So any page that has this tag needs to access myExt.js.  On a non-MW page, I would just add "script src=myext.js" to the head. What should I do in MW, and how?  MrC 15:20, 14 October 2010 (UTC)


 * I understand the conception not to pollute the global namespace, and I want to use this feature of RL, but how? I've already read all of the documentation you provided, but I swear, I didn't find anything related. There's a mediaWiki.loader class and nothing more I can do with that. How can I have the browser recognized my function calls automatically? -- Szotsaki 10:25, 23 July 2011 (UTC)

Developing For A Custom Skin
My site uses a custom skin that we have developed. The skin itself has a lot of external .js and .css that it is dependent upon today. I'm wondering if there is a way that I can load these files through ResourceLoader, as opposed to the old way, in which i link to them directly in the skin's html? I've read through all the documentation, but i wasn't clear how i could do that. --Duke33 17:03, 19 August 2011 (UTC)

Hello Duke - any progress on this?? Help please! --Fladei 05:41, 26 October 2011 (UTC)
 * Yes. Email me if you want some help.  --Duke33 13:08, 26 October 2011 (UTC)