User:NHW-Host-Bot/2026-005-consolidate-loaded-js
| NHW-2026-005 | |
|---|---|
| Reported | 2026-09-01 |
| Component | MediaWiki:Common.js, MediaWiki:Rumors.js, MediaWiki:Common.js/nhsympopup.js |
| Affects | Main Page and pages using {{Random true rumor}}; edit pages |
| Change | Load these scripts as part of Common.js instead of separately; move the rumor list to a data page |
| Status | ✅ Actioned — 2026-09-03, revisions 209035 and 209036 |
ACTIONED 2026-09-03. Both scripts now load as part of MediaWiki:Common.js, and the rumor list lives at MediaWiki:Rumors.json. Nothing a reader sees changed. The two old pages are kept for now, unloaded, so the change can be reversed; see #What was done.
Two site scripts were loaded through an old side-channel; folding them into Common.js and moving the rumor list to a data page removed that channel, with no change to what readers see.
Two of this wiki's site scripts were pulled in through a legacy loader rather than as part of MediaWiki:Common.js. They are now loaded the normal way, and the rumor text has moved out of JavaScript entirely. Nothing a reader sees changed.
Background
MediaWiki:Common.js is loaded automatically by MediaWiki on every page, through ResourceLoader. It in turn used the old importScript() helper to pull in two further pages:
- MediaWiki:Rumors.js — the "true rumor" that appears on the Main Page and anywhere {{Random true rumor}} is used. This file was 359 rumor strings with a four-line picker at the bottom.
- MediaWiki:Common.js/nhsympopup.js — the coloured-symbol picker dialog on edit pages.
importScript('X') fetched X as /index.php?title=X&action=raw&ctype=text/javascript. That is a different, older path from the ResourceLoader one that loads Common.js itself, and it was worth removing for three reasons below.
Why change it
1. Fewer places for site JavaScript to hide. Executable site JavaScript should live in as few, as visible, places as possible. Common.js is the canonical, watched page; scripts loaded from it by name are easy to overlook. Consolidating keeps all site JavaScript in the one place people already know to look.
2. The rumor list is content, not code. Adding or fixing a rumor used to mean editing a JavaScript file, where a stray quote or comma is a script error rather than a typo. The list is now an ordinary data page, edited as text: a mistake produces a wrong rumor, never broken JavaScript. Because a rumor is shown site-wide, that page is edit-restricted to administrators and interface administrators — a limited list, not open editing — so the same level of control is kept, just over content instead of code. The Main Page rotating screenshot already works this way, via Special:RandomInCategory.
3. It removes a special case in the site's edge protection. The index.php?…&action=raw fetch pattern requires a dedicated exception in the site's front-of-house request filtering so that these script loads are not challenged. Loading the scripts the standard way removes the need for that exception — one less special case to maintain and reason about.
What was done
2026-09-03.
- MediaWiki:Rumors.json created (revision 209035) — the 359 rumors as a JSON list. Because it is a
.jsonpage in the MediaWiki namespace it is editable only by administrators and interface administrators, and MediaWiki refuses to save it if the JSON is malformed. - MediaWiki:Common.js rewritten (revision 209036) — the rumor picker and the coloured-symbol picker are both inlined into it, and it now contains no
importScript()call at all. The rumor list is fetched throughapi.php, not theaction=rawpath. - MediaWiki:Rumors.js and MediaWiki:Common.js/nhsympopup.js were NOT deleted. Nothing loads them any more, but they are being kept for the moment so this change can be reversed by a single edit if something turns up. They will be deleted once the change has had time to settle.
- The edge exception is still in place, for the same reason: it is what a rollback would need. It will be removed after it has been confirmed unused, which takes longer than a day — browsers hold a cached copy of Common.js for a while, so requests for the old scripts keep arriving from stale caches for some time after nothing references them.
Reader impact
None. A random true rumor appears on the Main Page exactly as it did before, and the coloured-symbol picker works exactly as it did before — it was moved between files, not changed. ⚠ That is a change from this page's original wording, which counted on the picker being broken; see the note below.
⚠ The second component was revised on 2026-09-03 before being applied. This page previously said to stop loading the picker and let it go, on the grounds that it was already inactive — it asked for jquery.ui.dialog, a module removed from MediaWiki core in 1.43, so the dialog could never open. That was true when this page was written. It stopped being true: NHW-2026-006 item G repaired the picker on 2026-09-03 (revision 209029), moving it onto jquery.ui and jquery.textSelection. A working, NetHack-specific editing helper is exactly the kind of thing this wiki keeps, so this change carried it across rather than dropping it — the consolidated MediaWiki:Common.js took the repaired code as it stood.
How it was checked
The edge cache was purged first, so every check below ran against the new MediaWiki:Common.js rather than a stale copy.
- Anonymous, in a headless browser, on all three pages that use {{Random true rumor}} — Main Page, User:Paxed/Main Page and User:Bulwersator/test, enumerated from the API rather than typed in. Eight loads each: the rumor was always present, never empty, and always one of the 359 in MediaWiki:Rumors.json. Each page showed at least two different rumors across its loads, which is what distinguishes a working picker from the template's own fallback text — the fallback is itself one of the 359, so simply matching the list would not have proved anything. No page made any request to the old
index.phpscript path, and no page threw a JavaScript error. - Logged in, on a real edit form — clicking "Color symbols" opened the picker (16 colours, 95 symbols) and Insert symbol placed
{{white|@}}in the edit box. This is the check NHW-2026-006 used, re-run to prove the move did not break what it had just repaired. Nothing was saved. - The wider site-script sample — 72 checks across a markup-stratified sample of pages and all five skins, as an anonymous cookie-free reader: no errors, no content-security-policy violations, no unexpected failures.
Related, not part of this
The rest of MediaWiki:Common.js — the Main Page greeting, the talk-page signature check, Source: line highlighting, and the search-results click helper — is loaded correctly through ResourceLoader and was not affected. Whether any of it should move into an extension is a separate discussion.
The dead 2006 edit-toolbar buttons that used to sit in that list, and an uncalled helper function beside them, were removed on 2026-09-03 by NHW-2026-006 (revision 209027), so this change had less to carry across than when it was written.