You can put javascript code in the "MediaWiki:common.js" page of your wiki.
On a fresh new wiki you would be creating this page. Because it is in the "MediaWiki" namespace you may hit permissions problems. You cannot edit the page unless you are an admin user. Go to the page "Special:ListUsers/sysop" to see who the admin users are, and make sure you are logged in as one of them (can't remember the password?). Once you've overcome those hurdles and can edit "MediaWiki:common.js"...
You can place any javascript there, and it should load for all users regardless of their user group or skin choice (hence the name "common"). After changing it, remember your browser may be caching things. View any wiki page and do a ctrl+refresh, and the new javascript should kick in.
If you have javascript in a file which you want to load (either uploaded among your wiki files, or hosted on an external site) you can do this via ResourceLoader. Ilmari Karonen decribed how to do this as an edit to your LocalSettings.php, but another approach...
You can use ResourceLoader within your "MediaWiki:common.js" page. For example edit the page and just add the one line:
mw.loader.load( 'https://some.website.com/some-javascript.js' );
See the 'mw.loader.load' section in the mediawiki.org ResourceLoader/Modules docs.
We were using an addOnloadHook event which was intended to follow on from loading this, so we've ended up doing it the jQuery way:
jQuery.getScript( 'https://some.website.com/some-javascript.js',
function() {
addOnloadHook(function() {
someJavaScript.thingToRunOnLoad();
});
});