mw.user.clientPrefs

Manage client preferences.

For skins that enable the clientPrefEnabled option (see Skin class in PHP), this feature allows you to store preferences in the browser session that will switch one or more the classes on the HTML document.

This is only supported for unregistered users. For registered users, skins and extensions must use user preferences (e.g. hidden or API-only options) and swap class names server-side through the Skin interface.

This feature is limited to page views by unregistered users. For logged-in requests, store preferences in the database instead, via UserOptionsManager or mw.Api#saveOption (may be hidden or API-only to exclude from Special:Preferences), and then include the desired classes directly in Skin::getHtmlElementAttributes.

Classes toggled by this feature must be named as <feature>-clientpref-<value>, where value contains only alphanumerical characters (a-z, A-Z, and 0-9), and feature can also include hyphens.

Methods

get(feature) → {string|boolean}static #

Retrieve the current value of the feature from the HTML document element.

Parameters:

Name Type Description
feature string
Source:

Returns:

returns boolean if the feature is not recognized returns string if a feature was found.

Type
string | boolean
Retrieve the current value of the feature from the HTML document element.

set(feature, value) → {boolean}static #

Change the class on the HTML document element, and save the value in a cookie.

Parameters:

Name Type Description
feature string
value string
Source:

Returns:

True if feature was stored successfully, false if the value uses a forbidden character or the feature is not recognised e.g. a matching class was not defined on the HTML document element.

Type
boolean
Change the class on the HTML document element, and save the value in a cookie.