You can put javascript code on the "MediaWiki: common.js" page of your wiki.
In the new new wiki you will create this page. Since in the namespace "MediaWiki" you may run into permission problems. You cannot edit the page unless you are an admin user. Go to the "Special: ListUsers / sysop" page to find out which of the admin users are and make sure that you are logged in as one of them ( canβt remember the password? ). Once you overcome these obstacles and be able to edit "MediaWiki: common.js" ...
You can place any javascript there, and it should be downloaded for all users, regardless of their user group or skin choice (hence the name "general"). After changing it, remember that your browser can cache . Browse through any wiki page and do ctrl + refresh and the new javascript should start.
If you have javascript in the file that you want to download (downloaded from your wiki files or hosted on an external site), you can do this via ResourceLoader. Ilmari Karonen described how to do this as editing on LocalSettings.php, but a different approach ...
You can use the ResourceLoader on the "MediaWiki: common.js" page . For example, edit the page and just add one line:
mw.loader.load( 'https://some.website.com/some-javascript.js' );
See the "mw.loader.load" section in mediawiki.org ResourceLoader / Modules docs .
We used the addOnloadHook event, which should have followed the loading, so we ended up jQuery with it:
jQuery.getScript( 'https://some.website.com/some-javascript.js', function() { addOnloadHook(function() { someJavaScript.thingToRunOnLoad(); }); });
Harry wood
source share