MozillaZine

User.js file

From MozillaZine Knowledge Base

Revision as of 21:49, 8 September 2006; view current revision
←Older revision | Newer revision→

The user.js file, located in the profile folder, is used to customize preference settings in Mozilla-based programs. When you launch the application, the valid preferences you've added to user.js are then automatically copied into the prefs.js file (also located in the same profile folder), which stores all the preferences for the current user. For that reason, before you create or edit the user.js file it is advisable to make a backup copy of the prefs.js file. Although the prefs.js file can be modified using (about:config) or through the options and preference settings within the Firefox/Thunderbird/Mozilla Suite program's user-interface, the preferences you add via the user.js file will never be modified unless you yourself edit the user.js file contents. If you find that your preferences are not saved when you exit Firefox, it may be because your settings are superceded by the user.js file.

Contents

Creating the user.js file

The user.js file does not exist by default, and so you'll need to create the file before you can start adding your preferences. To do this, either use the ChromEdit extension (which creates the file automatically) or open a text editor such as Notepad and save the empty file as "user.js" inside your profile folder. (If you use a Windows text editor instead of ChromEdit, make sure you unhide extensions for known filetypes in Folder Options, so that the file isn't really called "user.js.txt". See also the manual editing advice.)

Adding user.js entries

To add preferences to user.js, either use the ChromEdit extension or open the file in a text editor such as Notepad, and type in the preference entries (and any comments) as follows. (After adding the entries, you must save the file! Changes will not take effect until you restart your Mozilla application.)

Valid preferences are entered via the user_pref command, as demonstrated below. "//" denotes a comment, so anything after these two characters on a line is ignored. A valid preference entry always begins with user_pref and always ends with a semi-colon; every preference must be entered on a new line. A preference consists of a ‘name’ (such as browser.chrome.site_icons) and a ‘value’. Values may either be integers (0, 2 etc.), booleans (true or false) or text (such as a file path). For example, you could add the following lines to your user.js file if you wished to disable bookmark icons:

// Don't show bookmark icons
user_pref("browser.chrome.site_icons", false);

Many Knowledge Base articles discuss individual preferences and their values. For a comprehensive list of valid preferences and their values, consult the about:config entries article.

Note that in Windows, if the preference value is a folder path then the path separator must be two backslashes. For example,

// Relocate parent directory for browser cache
user_pref("browser.cache.disk.parent_directory", "D:\\Mozilla\\Firefox\\"); 
// Relocate or share the browser bookmarks file
user_pref("browser.bookmarks.file", "D:\\Mozilla\\Firefox\\bookmarks.html");

Changing user.js entries

To edit user.js, either use the ChromEdit extension, or open the file in a text editor such as Notepad, make your changes, then close the file and save the changes.

To undo preferences that have been set in the user.js file:

  1. Remove the unwanted preference entries fom the user.js file as a first step. However, since the same preferences are now written to the prefs.js file, a second step is needed:
  2. If there are no options in the user interface (UI) for the preference, either directly edit the prefs.js file to remove the unwanted entries (not recommended) or reset the preference via about:config.

External links