Customizing Firefox - Default Preference Files

IMPORTANT: As of Firefox 21, there are two locations for default preferences, defaults/pref and browser/defaults/preferences. Because of the order in which Firefox loads files from these two locations, some preferences can't be set in defaults/pref. If you find a preference doesn't work in one location, try it in the other..

One of the most talked about subjects on the Enterprise Working Group Mailing List is customizing Firefox. There are quite a few different methods that people are using today, and there are more that people don't know about.

I'm going to do a series where I go over each method (that I know about) and detail how it works and what it can change. This should allow people that are customizing Firefox to make more informed choices about which method to use.

The first method we're going to talk about is adding default preference files.

If you go to the URL bar in your browser and type about:config, you'll see all of the various preferences that have been set in your browser. You'll notice that some of them are bold and some are not. You'll also notice that for the bold ones, it says "user set" in the Status column. These are the preferences that have been customized in your browser. The rest of the settings are marked "default" and are the default settings for the browser. (If you have some locked preferences, the status will say "Locked" and the preference will be in italics. We'll talk more about those in a later post.)

All of these preferences are stored in JavaScript files. Your customized settings are stored in a file called prefs.js in your profile directory. The default preferences are stored in various files like all.js or firefox.js. It is not recommended that you modify these files directly (and you can't easily, because they are stored in the file omni.ja[r]). You can, however, create your own Javascript files and place them in a location so that Firefox reads them as default preferences. That location is the defaults/preferences directory in the same location where the Firefox executable is placed. Files in this location will be used for all Firefox users (they are not profile specific).

Adding default preferences is as simple as creating a file with the extension of .js in the defaults/preferences directory and adding lines like:

pref("browser.rights.3.shown", true);

It's important that you get the format right based on the preference type. In this case, the preference is a boolean, so we specify true or false without quotes as the value on the right. If it is a string, you put it in quotes. If it is an integer, you put the value without quotes. You can tell the type of the preference by looking at the Type column in about:config.

In this example, we're setting a boolean value that tells Firefox that the rights notification has already been shown. This is the notification when you first run Firefox that says "Mozilla Firefox is free and open source software..."

All you can do with the default preferences file is set the default value of preferences. You cannot lock them and you cannot override user set preferences. (There's a bug open for locking via a default preferences file.) There are also preferences you can't set at all via this mechanism, like browser.startup.homepage. This preference is a complex preference and uses a different mechanism. We'll be talking about other methods can set this preference.

So using a default preference file is good if all you want to change is the default value for a few preferences. It doesn't let you lock preferences and it doesn't let you change the homepage.

Please note: I reserve the right to delete comments that are offensive or off-topic.

Leave a Reply

Your email address will not be published. Required fields are marked *

23 thoughts on “Customizing Firefox - Default Preference Files

  1. Thanks for starting this list. This is useful information and I'm glad someone is tracking the Enterprise product this way.
    I have one question, what if I want to change the defaults within firefox itself (perhaps in firefox/defaults/pref/, so I don't have to tweak user profiles? Would .js files and be honored for all users who run Firefox on this system?

    • The changes I've indicated in this post are definitely changes to firefox/defaults/pref and they will be honored for all users that run that version of Firefox.

      Most of the changes we'll be talking about in this series will apply to the installed Firefox, so they will happen to all users on the system (Or you can bundle the changes with a Firefox that you are distributing.)

  2. Hi Mike,

    Sorry to ask probably a newbie question - I am trying to set a default homepage for every firefox user and then allow them to change that if they like.

    To do so I have used local-settings.js and mozilla.cfg and used either a lockPref("browser.startup.homepage", "www.bbc.co.uk"); or a pref("browser.startup.homepage", "www.bbc.co.uk"); in mozilla.cfg to set the default. I have also tried defaultPref() but get the same results as commented yesterday by Stefan in https://bugzilla.mozilla.org/show_bug.cgi?id=775937.

    I am then trying to use a user.js to overwrite the setting defined for browser.startup.homepage on mozilla.cfg. I know my user.js works as I am able to change other settings but I can't change the browser.startup.homepage if it has been set by mozilla.cfg regardless if I use pref() or lockPref().

    Hope this makes sense and any help you can provide would be welcomed.

    Thanks in advance,

    Steve

    • The homepage must be a URL - http://www.bbc.co.uk

      What you want is a default pref, but to do a default pref, it can get weird. Use:

      defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://www.bbc.co.uk");

      and it should work.

      All this should work via CFG files.

      • Thanks Mike,

        Worked a treat!! Solved my problems. I have found your articles an excellent ready - keep them up.

        Steve

  3. I cannot get the lockpref to work. RH6.3, Firefox 18.

    I created mozilla.cfg at:
    /usr/lib64/firefox
    It contains two lines:
    //
    lockpref ("security.enable_ssl3", true);

    I created local-settings at:
    /usr/lib64/firefox/default/preferences

    It contains two lines:
    pref("general.config.obscure_value", 0);
    pref("general.config.filename", "mozilla.cfg");

    When I goto about:config, it still shows security.enable_ssl3 false.

    any ideas???

  4. Hello,

    I work as a System administrator in an international company.
    We wish to push some bookmark on users Firefox (15.0.1 for most of them).
    I look for a help everywhere but no way to do it.

    Can you please give me some tips ?

  5. I am looking for a way to non-customizable default header and footer. I read the above post to add a default/preferences so that I can change the default header and footer. But, I also need to inhibit the ability to modify them. All that can be permitted is to print. Any suggestions?

    Soo much good info here!

    Thanks

    • I'm surprised you were able to change them. They are quite painful to change. Did you use a printer name in the preference? Like:

      pref("PRINTERNAME.print_headerleft", "");

      If you were able to change them, you can lock them using:

      lockPref("PRINTERNAME.print_headerleft", "");

      in an autoconfig file. Although it looks like the user is changing them in the user interface, they value will not actually be changed.

  6. Hi mike, I'm a little confused; in this post you say that placing the Default Preferences file in Defaults\Prefs doesn't work anymore, that it has to go in Defaults\Preferences. I am assuming that you are talking about c:\Program Files\Mozilla Firefox\Defaults so I looked there and there is a Prefs folder but not a Preferences folder. I should say that I am using Firefox 25.0.1; is it possible that Mozilla has changed folders again? If not then my best guess is that I have to create the Preferences folder.

    I have a couple of other questions if I can remember what they are. I know I am wondering if there is any name that I should not use for the default preferences file. For example, could I call it Defaults.js?

    I can't remember what the other one was so I guess I'll have to try again some other time.

    Thanks,
    Tom

    • Yeah, it's quite confusing. Since these posts are a point in time, they don't convey it well.

      As of now, I only recommend configuring your AutoConfig file in defaults/pref and then configuring all preferences in an AutoConfig files.

      defaults/pref and browser/defaults/preferences can be unreliable because they depend on how Firefox chooses to load the preferences.

      As far as the filename goes, the reason I tend to use certain names is because Firefox loads them in alphabetical order.

  7. Mike, I remember what the other question was; I want to read the whole "Customizing Firefox" series but I can't figure out how to do that. I found "Customizing Firefox - Autoconfig Files" and then I found the link to this one. There seem to be a lot of other Customizing Firefox articles but they don't seem to be any that would fit in-between these two. If there are how can I find them.