User.js file: Difference between revisions

From MozillaZine Knowledge Base
Jump to navigationJump to search
(make it apply to all apps, redirect pref-specific info to about:config entries article, clean up)
(edited for clarity, additional information on creating user.js, added "Other References" section.)
Line 1: Line 1:
{{wrongtitle|title=user.js file}}
{{wrongtitle|title=user.js file}}


''user.js'' is a file in your [[Profile Folder | profile directory]] that contains preferences that will be loaded into Firefox/Thunderbird/Mozilla Suite every time it is started up. ''user.js'' is useful for making many preference changes at once; for small changes, [[about:config]] will probably be easier. The valid preferences in ''user.js'' are copied into ''prefs.js'', which is used to store all the preferences for the current user. Firefox/Thunderbird/Mozilla Suite will '''never''' modify the contents of ''user.js''.
''User.js'' is a user-created text file with a ".js" extension, located in your [[Profile Folder | profile directory]], that can be used to customize preference settings in Mozilla-based programs. Since the user.js file does not exist by default, you'll need to create the file  before you can start adding your preferences. The valid preferences added to the  ''user.js'' are copied into the  ''prefs.js'' file (also located in the same [[Profile Folder | profile directory]]) which then 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 current backup copy of the prefs.js file.  Although the prefs.js file can be modified using ([[about:config]]), or, in some cases, 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.


== Changing entries ==
== Creating the User.js file==  
 
If ''user.js'' does not exist in your [[Profile Folder | profile directory]], create it by opening Notepad or another text editor, type in the preference entries (and  comments) then save the file as "user.js".  (On Windows OS,  make sure you UNhide extensions for known filetypes in Folder Options, so that the file isn't really called "user.js.txt".
If ''user.js'' does not exist in your profile directory, create it. You can use a text editor to make changes.
 
Valid preferences are done via the user_pref command, as demonstrated below. '''//''' denotes a comment, so anything after these two characters on a line are ignored.


Valid preferences are done via the user_pref command, as demonstrated below. '''//''' denotes a comment, so anything after these two characters on a line are ignored. All valid preference entries begin with ''user_pref'' (followed by the preference name, a space, and the value) and always ends with a semi-colon. 
  // IE Favorites (bookmarks) are imported the first time Mozilla is run.
  // IE Favorites (bookmarks) are imported the first time Mozilla is run.
  // This preference is to determine whether they are shown in the bookmarks menu
  // This preference is to determine whether they are shown in the bookmarks menu
Line 14: Line 12:
  user_pref("browser.bookmarks.import_system_favorites", false);
  user_pref("browser.bookmarks.import_system_favorites", false);


To undo preferences that you set using the ''user.js'' file, you cannot simply delete the preferences that you inserted previously into ''user.js'', as these will remain written in ''prefs.js''. You should instead delete the preferences from ''prefs.js'' by editing that file with a text editor or via [[about:config]].
==Changing User.js Entries ==
To edit the user.js, open it within your text editor, make your changes, then close the file and save the changes.
 
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 preference is now written to the  ''prefs.js'', a second step is needed:
# Also remove the preference entries from ''prefs.js'', either  by direct editing of the prefs.js file (not recommended) or by modifying or resetting the preference via [[about:config]].


For a list of valid preferences, consult the [[about:config Entries]] article.
For a list of valid preferences, consult the [[about:config Entries]] article.
==Other References==
* [http://www.mozilla.org/support/firefox/edit Firefox Help: Editing Configuration Files]
* [http://www.mozilla.org/catalog/end-user/customizing/briefprefs.html A Brief Guide to Mozilla Preferences]
* [http://ilias.ca/userjs.html How to Create and Use the USER.JS in Windows]

Revision as of 19:33, 7 September 2005

User.js is a user-created text file with a ".js" extension, located in your profile directory, that can be used to customize preference settings in Mozilla-based programs. Since the user.js file does not exist by default, you'll need to create the file before you can start adding your preferences. The valid preferences added to the user.js are copied into the prefs.js file (also located in the same profile directory) which then 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 current backup copy of the prefs.js file. Although the prefs.js file can be modified using (about:config), or, in some cases, 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.

Creating the User.js file

If user.js does not exist in your profile directory, create it by opening Notepad or another text editor, type in the preference entries (and comments) then save the file as "user.js". (On Windows OS, make sure you UNhide extensions for known filetypes in Folder Options, so that the file isn't really called "user.js.txt".)

Valid preferences are done via the user_pref command, as demonstrated below. // denotes a comment, so anything after these two characters on a line are ignored. All valid preference entries begin with user_pref (followed by the preference name, a space, and the value) and always ends with a semi-colon.

// IE Favorites (bookmarks) are imported the first time Mozilla is run.
// This preference is to determine whether they are shown in the bookmarks menu
// Default: true (Show IE Favorites under bookmarks)
user_pref("browser.bookmarks.import_system_favorites", false);

Changing User.js Entries

To edit the user.js, open it within your text editor, 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 preference is now written to the prefs.js, a second step is needed:
  2. Also remove the preference entries from prefs.js, either by direct editing of the prefs.js file (not recommended) or by modifying or resetting the preference via about:config.

For a list of valid preferences, consult the about:config Entries article.

Other References