User.js file: Difference between revisions

From MozillaZine Knowledge Base
Jump to navigationJump to search
(Simplified the Intro and moved up front that the user.js file does not exist by default. "Changing user.js entries": you can also restore a prefs.js backup to undo preferences removed from user.js)
(Added to Intro that user.js is an advanced method that can be used instead of about:config. More info given under "About the user.js file")
Line 1: Line 1:
{{profile-file|filename=user.js}}
{{profile-file|filename=user.js}}


The ''user.js'' file is used to customize preference settings in Mozilla-based programs.  It does not exist by default so you'll have to create the file yourself and place it in the [[profile folder]].  When you launch your Mozilla application, valid preferences you've added to the user.js are automatically copied to the [[prefs.js file]] (located in the same profile folder) where all user-set preferences are stored. You should make a backup copy of the prefs.js file for that reason, before you create or edit the user.js file.
A ''user.js'' file is an alternative method of [[Editing_configuration#Modifying_preferences |modifying preferences]], recommended for advanced users onlyUnless you have a specific reason for wanting a user.js file, you should use [[about:config]] instead.   The user.js file does not exist by default.  


Although you can also use [[about:config]] or the options and preference settings within your Mozilla program's user-interface to modify your preferences, the ones  you set in the ''user.js'' file will '''never''' be modified unless you yourself edit the user.js file contents.  
'''Important: ''' Once an entry for a specific preference setting exists in the user.js file, you will not be able to change that setting within your Mozilla application's options and preference dialogs, or in [[about:config]], until you first remove the associated user.js entry or delete the user.js file.


==Creating the user.js file==  
==About the user.js file==
A user.js file can make certain preference settings more or less "permanent" in a specific profile, since you'll have to first delete or edit the user.js file to remove the entries before the preferences can be changed in the application.  This has the advantage of locking in certain preference settings.  A user.js file is also a way of documenting preference customizations and it makes it easier to transfer customized settings to another profile.
 
When you launch your Mozilla application, valid preferences you've added to the user.js file are automatically copied to the [[prefs.js file]] (located in the same [[profile folder]]) where all user-set preferences are stored.  For this reason, you should make a backup copy of the prefs.js file before you create or edit the user.js file.
 
==Creating the user.js file==
To create a user.js file, 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 [[Editing configuration/Manual editing | manual editing advice]].)
To create a user.js file, 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 [[Editing configuration/Manual editing | manual editing advice]].)


Line 25: Line 30:
  user_pref("browser.bookmarks.file", "D:\\Mozilla\\Firefox\\bookmarks.html");
  user_pref("browser.bookmarks.file", "D:\\Mozilla\\Firefox\\bookmarks.html");


==Changing user.js entries ==
==Editing user.js entries ==
To edit user.js, either use the [https://addons.mozilla.org/extensions/moreinfo.php?id=17 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 edit the user.js file, either use the [https://addons.mozilla.org/extensions/moreinfo.php?id=17 ChromEdit] extension, or open the file in a text editor such as Notepad, make your changes, then close the file and save the changes.  Note that removing or "commenting out" a preference line from the user.js file will not remove changes written to the [[prefs.js file]] (see below).  


==Removing user.js entries==
To undo preferences that have been set in the user.js file:
To undo preferences that have been set in the user.js file:
# 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:
# Edit the user.js file to remove the unwanted preference entries or delete the user.js file to remove all entries, as a first step.  Since the same preferences are now written to the  [[prefs.js file]], a second step is needed:
# 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), reset the preference via [[about:config]] or restore a backup copy of the [[prefs.js file]].
# 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), reset the preference via [[about:config]] or restore a backup copy of the [[prefs.js file]].


==See also==
==See also==
[[Resetting preferences]]
*[[Resetting preferences]]
*[[Editing configuration]]


==External links==
==External links==

Revision as of 18:53, 19 January 2007

A user.js file is an alternative method of modifying preferences, recommended for advanced users only. Unless you have a specific reason for wanting a user.js file, you should use about:config instead. The user.js file does not exist by default.

Important: Once an entry for a specific preference setting exists in the user.js file, you will not be able to change that setting within your Mozilla application's options and preference dialogs, or in about:config, until you first remove the associated user.js entry or delete the user.js file.

About the user.js file

A user.js file can make certain preference settings more or less "permanent" in a specific profile, since you'll have to first delete or edit the user.js file to remove the entries before the preferences can be changed in the application. This has the advantage of locking in certain preference settings. A user.js file is also a way of documenting preference customizations and it makes it easier to transfer customized settings to another profile.

When you launch your Mozilla application, valid preferences you've added to the user.js file are automatically copied to the prefs.js file (located in the same profile folder) where all user-set preferences are stored. For this reason, you should make a backup copy of the prefs.js file before you create or edit the user.js file.

Creating the user.js file

To create a user.js file, 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");

Editing user.js entries

To edit the user.js file, 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. Note that removing or "commenting out" a preference line from the user.js file will not remove changes written to the prefs.js file (see below).

Removing user.js entries

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

  1. Edit the user.js file to remove the unwanted preference entries or delete the user.js file to remove all entries, as a first step. 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), reset the preference via about:config or restore a backup copy of the prefs.js file.

See also

External links