MediaWiki:Common.js/doc

From Oxygen Not Included Wiki
Jump to navigation Jump to search

Overview

MediaWiki:Common.js is our main javascript that loads for every page. It's main purpose is to conditionally load other JavaScript modules based on the presence of specific CSS selectors on the current page. This was not done for performance, but to assure modularity and to keep scripts to their singular purpose. This solution is a temporary workaround until an upcoming module from wiki.gg automates this process.

This tactic was stolen, I mean inspired... Okay, it was copied over wholesale from the Ark Community Wiki Common.js and got ONI branding slapped on. It was written by Alex4401 who is a wiki.gg staffer, and can be contacted on the wiki.gg official Discord.

How it works

The ONI_ConditionalModules array contains objects that specify the CSS selector to check (sel) and the corresponding JavaScript pages to load (pages).

The ONI_ImportArticles function imports scripts with support for English and other languages. It strips the "en:" prefix for the English wiki or prepends "u:" for translations.

Conditionally Loaded Modules

The following Scripts are loaded conditionally:

Documentation inclusion is managed at MediaWiki:Clearyourcache.