-
-
Notifications
You must be signed in to change notification settings - Fork 225
user.js Syntax
The user.js
is a list of instructions you're giving to Firefox every time you restart the browser. Each instruction tells Firefox to set a preference to a specific value.
Every line that sets a preference follows this format:
user_pref("preference.name.here", value);
-
user_pref
: A command that tells Firefox, "Hey, I want to set a user preference." You'll see this at the start of almost every active line. -
("preference.name.here", value)
: This part is enclosed in parentheses.-
"preference.name.here"
: The name of the Firefox setting you want to change. It's always a string of text, wrapped in double quotes. These names can look a bit like website addresses, with dots separating different parts. For example,browser.startup.homepage
tells Firefox what page to load when it starts. -
,
: A comma separates the preference name from its value. -
value
: What you want to set the preference to. The type of value depends on the preference (see next section).
-
-
;
: Eachuser_pref
line must end with a semicolon. This tells Firefox that the instruction is complete.
There are three main types of values you'll use:
-
Boolean (True/False):
- Designate as either on or off.
- You'll use
true
(to turn it on) orfalse
(to turn it off). -
Example:
user_pref("browser.tabs.warnOnClose", false);
(This tells Firefox not to warn you when you close multiple tabs.) -
Important: Don't put quotes around
true
orfalse
. They are keywords, not text strings in this case.
-
Integer (Numbers):
- Require a whole number.
-
Example:
user_pref("network.http.max-persistent-connections-per-server", 6);
(This sets the maximum number of connections to a server to 6.) - Important: Just use the number. No quotes.
-
String (Text):
- Require text, like a URL or a file path.
- Strings must be enclosed in double quotes.
-
Example:
user_pref("browser.startup.homepage", "https://www.duckduckgo.com");
(This sets your homepage to DuckDuckGo.)
Sometimes you want to leave notes in your user.js
file to explain why you made a change, or to temporarily disable a setting without deleting it. You can do this with comments. Firefox ignores comments.
-
Single-line comment: Start the line with
//
. Everything after//
on that line is ignored.// This is a comment explaining the next line.
user_pref("some.setting", true); // This part is also a comment.
-
Multi-line comment (less common in
user.js
but good to know): Start with/*
and end with*/
. Everything between them is ignored./*
This is a comment
that spans multiple lines.
*/
- Typos: A misspelled preference name or an incorrect value type will mean the setting won't apply.
-
Missing Semicolons: Every
user_pref
line needs to end with;
. -
Quotes: Use double quotes for preference names and string values. Don't use them for booleans (
true
/false
) or integers. -
Activating Changes: Firefox only reads the
user.js
file when it starts up. So, if you make changes, you must restart Firefox to see them take effect.
The Betterfox project is a curated collection of these user_pref
settings. We've put a lot of thought into these defaults, but feel free to make it your own.