Help:Locating broken scripts

If you have problems with local gadgets or user scripts, these problems are often created by broken JavaScript code (the programming language that gadgets are written in) or undeclared dependencies on other code.

To track down the problematic code and place that needs fixing, you will have to use the developer tools of your web browser. This tool, combined with a special URL, will help you to identify the broken scripts.

Be sure you have an up-to-date configuration
First, ensure your browser is up to date. MediaWiki features and some scripts are not supported by old browsers for safety reasons.

Then, Purge>Special:MyLanguage/Manual:Purge|purge the cache for the page to force the page to be redisplayed from its source or scripts to restart.

Those two points solve most issues.

If you have a tool like "NoScript" or ad blockers installed on your web browser, then make certain that scripts are enabled for wikipedia.org, wikimedia.org, mediawiki.org, and wikidata.org.

Test if you have problems related to user scripts or gadgets
To test if your problem is linked to user scripts or gadgets, you can try to temporarily deactivate all on-wiki scripts at once.

To do so, add   to the web address (URL) of the page on which you see the problem. Example:  

If the URL already includes a  , append   instead. Example:  

If you still have problems on the page you are testing with the safe mode, and your browser is up to date, please contact a developer of MediaWiki (Report>Special:MyLanguage/How to report a bug|How to report a bug). If you don't have the problem anymore using the safe mode, it means you have an issue with a user script or gadget. You have to identify the problem.

Identify the problems
The following links explain how to do this for the following browsers: [https://developer.chrome.com/devtools Chrome/Chromium], [https://developer.mozilla.org/en-US/docs/Tools/Web_Console Firefox], [<tvar|IE>http://msdn.microsoft.com/en-us/library/ie/dn255006</> Internet Explorer], [<tvar|opera>http://help.opera.com/Linux/12.10/en/errorconsole.html</> Opera] and [<tvar|safari>https://developer.apple.com/library/mac/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/Introduction/Introduction.html</> Safari].

After opening them, please append <tvar|debug> </> to the web address (URL) of the page on which you see the problem. Example: <tvar|example> </>

If the URL already includes a <tvar|Qmark> </>, append <tvar|debug> </> instead. Example: <tvar|example> </>

If there is a problem with JavaScript, an error should be printed in the 'console' of the developer tools.

Make sure that "JavaScript" or "JS" is enabled here, and potentially disable other output so the output does not get too noisy:



Click on the file name on the right. This will open the "Debugger" view. The right pane will show the code which needs to be fixed. The left pane will show which file needs to be fixed (you might need to scroll through the list to find the one file that is highlighted). Right-click on the file, to open the file that needs fixing in a new tab:



Due to how files are "loaded", the exact URL of the file might not always be obvious. So you may have to scroll to the top of the file to see its name.

This name may just be a comment (something like <tvar|title> </>).

Problems that need fixing could be in the local <tvar|common>MediaWiki:Common.js</> file on that wiki, in your personal files such as <tvar|personal>User:MyUserName/common.js</> (or other .js files that you have under <tvar|subpages> </>), or in the code of one of the gadgets available on that wiki, or in the code dependency definitions of the gadget defined in <tvar|gadgetdef>MediaWiki:Gadgets-definition</> on that wiki.

For more technical information you can check toggle>ResourceLoader/Developing_with_ResourceLoader#Toggle_debug_mode</>|how to Toggle debug mode.

Fix the problem
You will find most of the scripts by looking in <tvar|globaljs>m:Special:MyPage/global.js</> on Meta, and locally <tvar|commonjs> </>, <tvar|vectorjs>Special:MyPage/vector.js </> (or similarly named pages, if you are using a different skin, such as <tvar|monobookjs>Special:MyPage/monobook.js </> if you are using the MonoBook skin), and anything that is selected locally in the <tvar|gadgets> </>.

Problem on scripts can be due to multiple causes. We advise you to contact someone who knows JavaScript to help you. (If you have basic technical knowledge of JavaScript, see <tvar|Phab>T164242</> for hints and links to additional information.)

In the meantime, you can disable the scripts.

If the broken script is identified as a gadget, disable the gadget in your preferences.

If the broken script is on a <tvar|js>.js</> page or yours, disable the script by commenting it out. Add <tvar|comment1> </> at the beginning of the concerned code and <tvar|comment2> </> at the end.

You can also disable the script by blanking all of the lines about it in your <tvar|js>.js</> page.

Other ways to identify broken scripts

 * 1) note the gadgets and scripts you are using on your account
 * 2) disable all scripts and gadgets on your account
 * 3) re-enable one gadget
 * 4) clear your cache
 * 5) test if you still have problems:
 * 6) * If not, go to step 3
 * 7) * If yes, fix the script and go back to step 3 for other potentially broken scripts

Totally unrelated gadgets can break the strangest things.

To narrow it down turn off all the gadgets in a particular section of the gadgets list in preferences, and see if that helps.

Then if that doesn't work try turning off another section of gadgets.

Eventually you will find the section of gadgets where the problem lies.

Then turn off the gadgets in that section one by one.

Before doing any of this take a screenshot of the whole gadget preferences page.

This way you can get back to what you like.

Firefox has a built-in screenshot tool that lets you get the whole page including the part of the page not showing on the screen.