Forum:How to .. override/nullify/disable/replace a JS function

I may not be using the correct terminology in the above title so educate me if you know the right jargon. In the context of javascript used for adding functionality or tweaking the Document Object Model (DOM) we have several JS files that are sourced (src) and/or generated (&gen=js&useskin=monaco). The relative order in which the contained JS functions get declared is predetermined and (with some guidance) is visible/knowable via the page source view.

Assuming that I do not have sysop rights, if I wish to surgically replace/override/disable a JS function that might be already sourced via a MediaWiki:Common.js or MediaWiki:Monaco.js file then is there some way to declare that same-named function within either of my personal customization files (w:c:central:Special:MyPage/global.js or Special:MyPage/Monaco.js) in such that my latest sourced function declaration takes precedence over any prior declaration of the same named function?
 * Question:


 * Does the answer depend on what event triggers the two JS function? (If so, then the event of interest to me is the onload event a.k.a. ready in jQuery. ie. the instant the DOM is ready to be traversed and manipulated.

This came up while testing various versions of the ShowHide.js javascript and for that I had access to a pristine test wiki where I was able to ensure that no MediaWiki messages were prescribing JS for the wiki pages. However,creating an entire wiki as a personal (non-production) sandbox does not seem like the most efficient way of tackling this type of problem. (i.e. If every tom, dick and harry did the same then it might become untenable.)
 * This is not one of those cases where w:c:CommunityTest or w:c:smwtest would have helped.

With a test wiki I was able to switch among several sources easily by using the  directive and in doing so, I could completely avoid the situation where two same-named functions are being declared one after the other.


 * How might I have done this at a live/production wiki in a way that only affects how my user account sees the wiki pages and not affect other visitor's reliance on whatever same-named function is declared in a MediaWiki message (or sourced from some other Wikia location, for that matter)?

-- najevi 06:03, November 25, 2009 (UTC)