Christoph Polcin

Firefox Tweaks

Some Firefox per­for­mance tweaks

Store your profile in a virtual memory filesystem aka TMPFS

  1. create a mount entry to keep your profile in memory, edit /etc/fstab and adjust <XXX>

    tmpfs   /home/<USER>/.mozilla/firefox/<PROFILE_ID>.default \
                tmpfs \
                size=196M,noauto,user,exec,uid=<UID>,gid=<GID> \
            0 0
    
  2. create a sync directory to persist your profile during reboots

    mkdir ~/.mozilla/firefox/<PROFILE_ID>.default.sync
    
  3. save this shell script under ~/bin/ffsync.sh

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    #!/bin/sh
    # syncs a firefox profile with a storage directory
    # www.christoph-polcin.com
    
    # Change this to match your correct profile
    ID="<PROFILE_ID>.default"
    
    PROFILE="${HOME}/.mozilla/firefox/${ID}"
    
    EXCLUDES="--exclude .unpacked \
        --exclude lock \
        --exclude .parentlock \
        --exclude Cache \
        --exclude Cache.Trash \
        --exclude urlclassifier*";
    
    [ ! -e "$PROFILE" ] && exit 1
    
    if ! grep -Fqs "${PROFILE}" < /etc/mtab; then
        mount "${PROFILE}"
        if ! grep -Fqs "${PROFILE}" < /etc/mtab; then
            exit 1
        fi
    fi
    
    if test -f "${PROFILE}/.unpacked"; then
        rsync -avq --delete ${EXCLUDES} "${PROFILE}/" "${PROFILE}.sync/"
    else
        rsync -avq "${PROFILE}.sync/" "${PROFILE}/"
        touch "${PROFILE}/.unpacked"
        # optimizes databases
        find "${PROFILE}" -name \*.sqlite \
            -exec sqlite3 {} vacuum \; \
            -exec sqlite3 {} reindex \;
    fi
    
  4. create a cron job to trigger the sync

    crontab -e
    */8 * * * * ~/bin/ffsync.sh
    
  5. invoke this script during boot or in ~/.xinitrc

Custom settings

Look up details at Mozil­laZine Knowledge Base.

// ~/.mozilla/firefox/__PROFILE_ID__.default/user.js
// www.christoph-polcin.com
// vim: ft=javascript foldmethod=marker

// ui {{{
user_pref("image.animation_mode", "none");
user_pref("browser.fullscreen.animateUp", 0);
user_pref("browser.panorama.animate_zoom", false);
user_pref("browser.tabs.animate", false);
user_pref("browser.urlbar.hideGoButton", true);
user_pref("browser.urlbar.autoFill", true);
user_pref("browser.urlbar.clickSelectsAll", true);
user_pref("layout.word_select.eat_space_to_next_word", true);
// }}}

// search {{{
user_pref("keyword.URL",
    "https://duckduckgo.com/?kc=1&kd=-1&ke=-1&kg=g&kh=1&ki=1&kj=b2&kk=s&km=l&kn=1&kp=-1&kq=-1&kr=-1&ks=m&kv=-1&kw=w&kx=o&kz=1&k1=-1&k2=1&q=");
user_pref("accessibility.typeaheadfind.casesensitive", 0);
// }}}

// safe browsing {{{
user_pref("browser.safebrowsing.enable", false);
user_pref("browser.safebrowsing.malware.enable", false);
// }}}

// security {{{
user_pref("security.ssl.treat_unsafe_negotiation_as_broken", true);
user_pref("security.ssl.require_safe_negotiation", true);
// }}}

// tabs {{{
user_pref("browser.tabs.loadBookmarksInBackground", true);
user_pref("browser.tabs.loadInBackground", true);
user_pref("browser.tabs.warnOnClose", false);
user_pref("browser.tabs.warnOnOpen", false);
// }}}

// downloads {{{
user_pref("browser.download.manager.closeWhenDone", true);
user_pref("browser.download.useDownloadDir", false);
// }}}

// core {{{
user_pref("config.trim_on_minimize", false); // disable swap
user_pref("browser.shell.checkDefaultBrowser", false);
user_pref("pref.advanced.javascript.disable_button.advanced", false);
user_pref("nglayout.initialpaint.delay", 0); // render page immediately
user_pref("plugin.expose_full_path", true);
user_pref("content.interrupt.parsing", true);
// }}}

// cookies {{{
// 0: all allowed
// 1: Only cookies from the originating server are allowed.
// 2: disable all
user_pref("network.cookie.cookieBehavior", 1);
user_pref("network.cookie.lifetime.days", 1);
user_pref("network.cookie.lifetimePolicy", 2);
// }}}

// network {{{
user_pref("network.dns.disableIPv6", false);
user_pref("network.http.pipelining", true);
user_pref("network.http.pipelining.maxrequests", 6);
user_pref("network.http.pipelining.ssl", true);
user_pref("network.http.proxy.pipelining", true);
user_pref("network.http.max-connections-per-server", 12);
user_pref("network.http.sendRefererHeader", 0);
user_pref("network.prefetch-next", false);
// }}}

// scripts {{{
user_pref("dom.allow_scripts_to_close_windows", false);
user_pref("dom.disable_window_move_resize", true);
user_pref("dom.disable_window_status_change", true);
// }}}

// dev {{{
user_pref("view_source.editor.external", true);
user_pref("view_source.editor.path", "/usr/bin/gvim");
// }}}