Open-Source Wikis

/

Gecko

/

Primitives

/

Preferences (libpref + StaticPrefs)

mozilla/gecko-dev

Preferences (libpref + StaticPrefs)

Firefox uses preferences for almost every configurable behavior. Internally, prefs are read from prefs.js in the profile (and from per-component default .js files in the build), and surfaced via two APIs.

libpref

modules/libpref/ implements the legacy pref system. APIs:

Preferences::GetBool("browser.foo", false);
Preferences::SetBool("browser.foo", true);
Preferences::AddBoolVarCache(&sCache, "browser.foo");
Services.prefs.getBoolPref('browser.foo', false);
Services.prefs.setBoolPref('browser.foo', true);

Defaults are loaded from:

User-modified prefs persist to prefs.js in the profile.

StaticPrefs

For performance, prefs that are read repeatedly use StaticPrefs: pre-generated C++ accessors with a cached value updated on pref change.

Defined in modules/libpref/init/StaticPrefList.yaml entries:

- name: dom.foo.enabled
  type: RelaxedAtomicBool
  value: false
  mirror: always

Generates:

mozilla::StaticPrefs::dom_foo_enabled();   // dot → underscore

mirror: always keeps the cache consistent; mirror: once snapshots at startup.

Categories of prefs

  • dom.* — DOM features (often gates new specs).
  • network.* — networking knobs (network.http.*, network.dns.*).
  • privacy.* — anti-tracking, fingerprinting.
  • security.* — TLS, sandbox, permissions.
  • browser.* — desktop UI behavior.
  • extensions.* — extensions runtime.
  • devtools.* — DevTools UI.
  • gfx.* — graphics features and blocklists.
  • media.* — codec enablement, autoplay.
  • fission.* — site isolation.

Tooling

  • about:config — UI to view/edit prefs.
  • Services.prefs.savePrefFile(null) — flush to disk.
  • Preferences::Lock(...) — make a pref read-only.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Preferences (libpref + StaticPrefs) – Gecko wiki | Factory