Available from version 1.38.0 (Gerrit change 752369)
Exclude a user option from the preloaded data for client-side mw.user.options.
Define function:
public static function onResourceLoaderExcludeUserOptions( array &$keysToExclude, Context $context ) { ... }
Attach hook: In extension.json:
	"Hooks": {
		"ResourceLoaderExcludeUserOptions": "MediaWiki\\Extension\\MyExtension\\Hooks::onResourceLoaderExcludeUserOptions"
Called from: File(s): ResourceLoader/ResourceLoader.php, ResourceLoader/UserOptionsModule.php
Interface: ResourceLoaderExcludeUserOptionsHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:ResourceLoaderExcludeUserOptions extensions.



This hook is called on every index.php pageview (via ResourceLoader\UserOptionsModule), and when building responses for the "mediawiki.base" module. Avoid database queries or other expensive operations as that would increase page load time.

Use this hook to optimize pageview HTML size by omitting user preference values from the export JavaScript data for mw.user.options. For example, when an extension stores large values in a user preference, and rarely or never needs these client-side, you can exclude it via this hook. (T251994)

This will exclude both the default value (via mediawiki.base module) and the current user's value (via pageview HTML).