User:MusikAnimal/scriptManager

scriptManager is a script for users who use a lot of scripts. It allows you to selectively run scripts on the fly, rather than having every script ran on every page. Even if you don't use some given script, it's still being downloaded by your browser and/or being ran in it's entirety. This is especially a problem with slower connection speeds and internet plans with limited data.

When enabled, a new heading, "Enable scripts", will show up on your side bar. Under it will be the list of scripts you've added to scriptManager. From there, simply click on whatever script you want to enable.

Use cases
An example is the ArticleInfo gadget. This awesome script is ran on every page, making an AJAX call to gather data about the page such as the number of users watching it, pageviews over the past 30 days, and other cool stuff. Some pages you don't really care what the stats are... and you're making unnecessary AJAX calls. So if you add it to scriptManager, the script will only be ran when you tell it to.

Another example is the AfC script. The "review" link only shows up on AfC submission pages, but the script is still loaded in its entirety on every page. No need for that, add it to scriptManager and enable it only when you need it.

Setup
Setup may require some basic JavaScript knowledge. However, if you follow these instructions carefully, it should work fine.

Step 1: Add scriptManager
First add scriptManager to your skin's JS file (such as vector.js), or to your common.js to enable scriptManager on all skins:

Or to use scriptManager on all Wikimedia projects add the following to meta:Special:MyPage/global.js:

Step 2: Comment out other scripts
Any scripts you want to be handled with scriptManager must no longer be imported, as that will be done by scriptManager. You can simply comment out those lines of code by adding two forward slashes at the beginning of that line. Here I have my old common.js and my new one.

Before:

After:

It is recommended you keep any "backlinks" of scripts that you are using. Those let the author know how many people are using their script.

Step 3: Add scripts to scriptManager
Here it is important that you get the syntax right. To add scripts to scriptManager, we will use the full URL of where the script is located (because some scripts are on different wikis). The syntax is as follows:

replacing  with the name of the script (you can name it whatever you want),   with the corresponding project if it's not enwiki, and   with the location of the script on that project. This variable definition needs to go at the top of the JS file. Also note that this is a comma-separated list, so each entry should have a comma at the end except the last entry.

So, the above example of xtools, AfC helper, MOSNUM dates, and importWatchlist would look like this:

NOTE: All gadgets available in your preferences can be added to scriptManager. You'll need to disable the gadget, and instead add the source URL to scriptManager. Each gadget lives in the MediaWiki namespace. For a full list, see Special:Gadgets. Each gadget listed will have a link to the source.

Help
If you need help, just contact me. I'm an interface admin and can edit your JS files, and I'm more than happy to set up scriptManager for you if you'd like.