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:
modules/libpref/init/all.js— top-level defaults.- Per-component
.jsfiles (e.g.,browser/app/profile/firefox.js).
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: alwaysGenerates:
mozilla::StaticPrefs::dom_foo_enabled(); // dot → underscoremirror: 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.
Related
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.