Wikimedia Developer Support

How to detect with JavaScript if this wiki uses SUL?

Hello. What is the best way to determine if my script is running on a wiki using Wikimedia’s SUL ( Alternatively, a complete list of wikis using SUL is needed, best if machine-readable. There are pages such as and, but there is no info as to whether a speicific site uses SUL or not (for example, and don’t).

Have found that SUL wikis all have

<link rel="dns-prefetch" href="//" />

but that’s probably unreliable.

1 Like

The definitive answer can be queried from the SiteMatrix API:

Wikimedia wikis without SUL are marked with one of "nonglobal": true,"private": true, or "fishbowl": true.

If you merely need to know if you’re on a WMF wiki vs a third-party wiki, then a simple regex might be easiest. For exampe, based on WikimediaDebug/manifest.json:

var rWMF = /(^|\.)(mediawiki|wikidata|wikibooks|wikimedia|wikinews|wikipedia|wikiquote|wikisource|wikiversity|wikivoyage|wiktionary).org$/;
if (rWMF.test(

But if you’re looking for something onofficial that’s more specific to SUL, then what you started with actually seems fine. Note though that the dns-prefetch is from CentralNotice, not CentralAuth.

The current wmf-config shows that it is fine to assume any CentralNotice wiki also has CentralAuth. But there are a few rarer cases where CA is enabled without CN, so you’d miss those:

'wmgUseCentralNotice' => [
	'default' => true,
	'private' => false,
	'fishbowl' => false,
	'nonglobal' => false,

	'advisorywiki' => false,
	'lockeddown' => false,
	'fiwikimedia' => false,
	'qualitywiki' => false,

'wmgUseCentralAuth' => [
	'default' => true,
	'private' => false,
	'fishbowl' => false,
	'nonglobal' => false,

Example check (querySelector returns null|HTMLElement, casted to false/true):

var isWmfCa = !!document.querySelector('link[rel=dns-prefetch][href*=""]');
1 Like

Thanks for a comprehensive answer.

@Krinkle Some kind of a config value, like mw.config.get('wgUsesCentralAuth') would be great, I think. By the way, Central Notice seems to have its own mw.config values, like mw.config.get('wgCentralBannerRecorder'). Do you think I should use any of those instead of fetching the 'link[rel=dns-prefetch][href*=""]' element?

And another idea. As we discussed in IRC, I’m trying to detect SUL to find out whether I can use global preferences. So, probably, the best solution in my case would be to forget about SUL and just check the presence of the GlobalPreferences extension by using, say, mw.loader.getState('')? Non-SUL sites like foundationwiki, wikitech seem not to have this extension. Do you think that would be reliable?

On a CentralAuth wiki, the user will either have some cookies with a centralauth_ prefix or a CentralAuthAnon key in localStorage (although there is a small delay in setting one of these during the user’s first visit). This should work on any wiki with a reasonably recent CentralAuth version (older ones had CentralAuthAnon as a cookie, IIRC) as long as they have configured CentralAuth in a somewhat Wikimedia-like fashion.

Test whether Special:CentralAuth or the module action=centralauthtoken exists would be a more robust check, but those take an API request or something equivalent.