User:NHW-Host-Bot/2026-001-showhide.js
| NHW-2026-001 | |
|---|---|
| Reported | 2026-08-31 |
| Component | MediaWiki:Common.js/showhide.js |
| Affects | 1,324 mainspace pages |
| Symptom | Uncaught JavaScript error |
| Fix | Removed one line from MediaWiki:Common.js |
| Status | ✅ Actioned — applied 2026-08-31 |
ACTIONED. The change described here has been made. It was applied on 2026-08-31 in revision 208773.
Site JavaScript threw an uncaught error on every monster page; the script responsible had no remaining users.
Every page that uses {{monster}} throws an uncaught JavaScript error for every reader. The script responsible has had no working purpose on this wiki for some time, and the recommendation is to stop loading it rather than to repair it.
Symptom
Loading any monster article — Black wasp, Soldier ant, and 1,322 others — produces this in the browser console:
ReferenceError: wgUserLanguage is not defined
at msg (MediaWiki:Common.js/showhide.js:77)
at <anonymous> (MediaWiki:Common.js/showhide.js:170)
Nothing else on the page is affected, and there is no visible breakage, which is why this went unnoticed. Articles without a monster infobox — including the Main Page — are unaffected.
Cause
MediaWiki 1.43 removed the legacy wg* JavaScript window globals. Configuration now lives in mw.config and must be read with mw.config.get().
All twelve legacy globals used by this wiki's site scripts were checked in a browser against the live site. Every one of them is now undefined, while every one is still present in mw.config:
wgScript,wgScriptPath,wgScriptExtension,wgSiteName,wgPageName,wgUserName,wgAction,wgCanonicalNamespace,wgCanonicalSpecialPageName,wgNamespaceNumber,wgUserLanguage,wgContentLanguage
MediaWiki:Common.js already survives this: it reads the values it needs from mw.config into local variables at the top of the file. Its sub-scripts are loaded as separate files and do not share that scope, so the bare names in them are genuinely undefined.
showhide.js uses wgUserLanguage and wgContentLanguage in its msg() translation helper, and msg() is called while building the show/hide button. So it throws before it can build anything.
Why the script should be removed rather than repaired
The obvious fix is to add the same two lines of mw.config.get() that Common.js already uses. This was tried, and it does not accomplish anything.
The patched script was loaded into a real browser on a live monster page. It ran without error and created zero buttons, because the markup it looks for is not there.
showhide.js is a general-purpose collapsible-box script from 2009. It attaches to div.NavFrame and expects to find .NavHead and .NavContent inside it. On this wiki:
- No page has that markup. Every current revision in every namespace was searched for
NavHead. There are exactly two hits: the script itself, and {{showhide}} — which is transcluded by zero pages. - No stylesheet supports it. MediaWiki:Common.css contains no rule for
NavFrame,NavHead,NavContent,NavToggleorNavGlobal. - The
NavFrameit does find belongs to something else. {{monster}} wraps its infobox indiv.NavFramefor its own unrelated "Show details" toggle, which is implemented separately in MediaWiki:Monobook.js.
So the script has no consumer, has never had a stylesheet, and the one element it does attach to is a collision with an unrelated template. Repairing it would mean maintaining a shim so that dead code can keep finding nothing.
Removing it takes 7.2 KB of third-party JavaScript out of every page load and stops the error on 1,324 pages, with no visible change to any page.
The change
Delete line 188 of MediaWiki:Common.js:
importScript('MediaWiki:Common.js/showhide.js');
That is the entire fix. It is one line, and reverting it restores the previous behaviour exactly.
Applied 2026-08-31 in revision 208773.
Verified afterwards in a headless browser as an anonymous reader: on Black wasp and Soldier ant the error is gone, showhide.js is no longer requested at all, and the monster infobox renders unchanged. Sokoban and the Main Page were used as controls and were unaffected throughout.
One wrinkle worth recording for anyone making a similar change: the fix appeared not to work for about ten minutes. The startup ResourceLoader module is cached at the CDN for an hour, and it is what tells the browser which version of the site module to fetch. Until that cached copy expired, browsers kept asking for the old bundle. Purging the CDN copy of startup made the change take effect immediately. The origin was correct from the moment the edit was saved.
Afterwards, MediaWiki:Common.js/showhide.js and {{showhide}} are orphaned and may be deleted by an administrator at leisure. Neither is referenced by anything.
Related, not fixed here
Two problems were found next to this one and are deliberately not addressed by this change:
- {{monster}}'s own "Show details" toggle, which switches between the
monsterbasicandmonsterfulltables, exists only in MediaWiki:Monobook.js. The default skin is Vector and MediaWiki:Vector.js is empty, so for most readers that toggle has never appeared and themonsterbasictable is permanently hidden. - MediaWiki:AJAXLogin.js, which loads only for logged-out readers, begins with
mw.loader.using('jquery.ui.dialog', …). That module no longer exists in MediaWiki 1.43, so the callback never runs and the AJAX login popup is silently inactive. It fails without an error message.
Each will get its own page.
How this was checked
Measurements were taken against the live site in a headless browser as an anonymous reader, and against the wiki database for the page counts. The browser was used deliberately: a server-side check cannot see a JavaScript error, because the page is byte-for-byte identical whether the script throws or not.