Firefox optimization and troubleshooting thread

来源:互联网 发布:分布式数据库 pec模块 编辑:程序博客网 时间:2024/06/07 22:55


The objective of this thread is to provide a simple, but comprehensive, list of optimizations for Firefox and help with troubleshooting common issues (this is a work in progress).
Index
Benchmarks 
Profiles 
Backups 
Database Optimization 
Extensions Optimization 
Speed Optimization 
Flash Optimizations 
Running Profiles from RAM 
Installing Other Versions 
Other Optimizations 
Troubleshooting 
Compiling Firefox 
Benchmarks
Performance
First of all, I would recommend to bookmark the Peacekeeper benchmark page and perform some benchmarks to establish a base performance index on your machine. 
This benchmark could present variable results depending on what you are running simultaneously with Firefox, how many and which extensions you have. So I recommend doing all tests just after booting and using a clean Firefox profile, so you can establish a base for comparison.
For example, here are my benchmarks, showing the difference between browsers and the improvement I have achieved since I installed Jaunty.

Firefox optimization and troubleshooting thread - lagignition - lagignition

Note: "Firefox 3.5 optimized" is the official final version from Mozilla, compiled from source with optimization flags for my processor family. PGO (Profile-Guided Optimization) is also used since July 5th tests.
Bandwidth
Another benchmark tool that can be useful is Speedtest.net, which allows to determine if you have speed issues on your connection.
Page Loading
Extended Statusbar - is a Firefox extension that adds a statusbar with speed, percentage, time and loaded size (similar to Opera's one) 
Profiles
Firefox uses profiles to store configuration data. Each profile has it's own folder and it contains all your bookmarks, extensions, passwords, cookies and other stuff. 
Profiles are stored in your home directory, under the hidden folder .mozilla/firefox/. To see it, you need to hit CTRL+H when browsing home. The default profile folder name has a series of random letters and number, followed by .default (example: ydtehagr8ja.default).
You can create any number of profiles you want. They won't affect each other. To create a new profile, close Firefox the open "Applications >> Accessories >> Terminal", then paste (CTRL+SHIFT+V) the code below in the terminal window and hit enter:
Code:
firefox -P

It will launch the Profile Manager, from where you can create, delete and start profiles.
For a full list of command, visit https://developer.mozilla.org/en/Command_Line_Options
Backups
Firefox profiles can become corrupted and cause several problems. So, backing up your profile is the best way to avoid them. You can do that by simply copying the contents of ~/.mozilla/firefox/ or using FEBE extension, which allows to schedule backups of your entire profile or some parts of it, then easily restore them.
You can learn how to use FEBE here.
You can also easily backup/restore bookmarks using Firefox Bookmark Manager. Open "Bookmarks >> Organize Bookmarks" then select one of the options of the "Import and Backup" drop-down menu. Firefox also makes regular backups of your bookmarks, than can be restored through the same menu.
Another option would be using an online synchronizing tool like Xmarks or Mozilla Labs - Weave Sync. See other options here.
Database Optimization
Firefox stores a lot of data, for example bookmarks, into standalone sqlite [wikipedia.org] database files. They can be found in your profile directory and have the extension .sqlite (for example places.sqlite). While sqlite databases are very practical, because don't need a server to run, sometimes they can become very slow. I don't know exactly how it happens, but some data is not completely removed when you delete entries and this can increase the size of the database considerably, slowing down the database performance.
You can avoid this problem by optimizing Firefox databases to remove the junk data:
1 ) install sqlite3
2) Create a new empty file in your script directory (usually ~/bin) and rename it to firefox-optimize, then add the code below to it and save it. 
Code:
#!/bin/bash    killall firefox  find $HOME/.mozilla/ \( -name "*.sqlite" \) -exec sqlite3  {} "vacuum" \;

Then make it executable and run it from the terminal.
Code:
firefox-optimize

The script above will basically search for all sqlite databases on the ~/.mozilla folder and execute the vacuum command, to remove junk data. 
Quote:
Note: Thanks to martinbaselier for rewriting my script entirely, making it almost a single line 
If you want to optimize a single database then run the command below, replacing the path accordingly:
Code:
sqlite3 $HOME/.mozilla/firefox/yourprofile/places.sqlite "vacuum"

Doing this can improve performance considerably, specially if you like to use bookmark extensions likeTagSifter.
Extensions Optimization
The availability of extensions is one of the main reasons I use Firefox. They provide lots of interesting and useful features, but they can also slow down Firefox considerably. As you can see from my benchmarks, when I run Firefox with several extensions, the performance drops about 20-40%. I'm currently using 43 of them. You can see my extension collection here.
Some extensions might slow down Firefox more then others. Finding which extensions are slowing you down more is not so simple, but the simplest way to do it is too disable all of them, then enable one by one and test Firefox, until you can pinpoint the culprit. 
To disable extensions open "Tools >> Addons", then select the "Extensions" tab, then select the extension you want to disable and click the "Disable" button. You need to restart Firefox to make this effective, since all extensions files are loaded when you start Firefox. Also check the Problematic Extensions in the Mozilla Knowledge Base site.
If you don't want to get rid of slow extensions, then you could disable extensions that you don't use very often and enable them only when you need. The extension QuickRestart will make the process of enabling/disabling extensions easier. You can also avoid the need to restart Firefox by using the Extension Developer extension. It has a toolbar button that allows you to reload Firefox extensions without closing it. Nevertheless, you might experience some weird behaviors while using it.
Another approach could be creating specific purposes profiles. For example you have an extension that you use only eventually on a couple of sites, you could create a profile with the extensions you need for regular use and another profile with the extensions you don't use regularly. You can launch multiple profiles when you need them using the -no-remote option (see Profiles section).
Speed Optimization
Extensions
FasterFox - Performance and network tweaks for Firefox. Fasterfox allows you to tweak many network and rendering settings such as simultaneous connections, pipelining, cache, DNS cache, and initial paint delay.
Fasterfox Lite - This is based on FasterFox, but without prefetching. Prefetching was removed for this Lite version because it wasted a lot of server bandwidth as well as causing unnecessary server load.
AdBlock Plus: prevents unnecessary and annoying content from loading. This might speed up some pages and it will certainly make your web experience more enjoyable.
Quote:
Warning: I don't like to use FasterFox extensions, because I have noticed that Firefox uses a lot more memory than usual. It seems to me that FasterFox has a problem of leaking memory, which slows down Firefox responsiveness considerable after a few hours of usage. This can be solved by restarting Firefox, but you can achieve the same results of FasterFox by editing the preferences manually (see next topic).
Firefox Preferences Tweaks
Firefox stores it's preferences in a file called prefs.js in your profile folder, but you don't need to edit this file manually. Most common settings can be changed through Firefox menu, by opening "Edit >> Preferences". Additional settings can be changed by typing about:config in the address bar. This will open the preferences file directly in the Firefox window.
The first time you open the about:config page it will warn you about voiding warranty (???) and possible damages that you could cause. If you mess with the settings so badly that you can run Firefox properly, then simply restore a backup of your profile (see Backup section) or delete the prefs.js file and restart Firefox.
To modify a Preference values in the about:config page you can:
double-click in the preference to toggle it's value if it is boolean type (true or false) 
right-click on the preference and select the "Reset" option, in case the default value has been modified (bold font) 
right-click on the preference and select the "Modify" option, in case the value is not boolean (integer or string) 
To create a new Preference, right-click anywhere and select the "New" option, then "String", "Integer" or "Boolean". The first if for complex values, the second is for numbers and the third is for true or false.
Some preferences tweaks can improve performance of loading pages and content. There are several tutorials out there about this. The following one is very popular and covers most of the commonly suggested changes (some also changed by FasterFox extension).
http://www.ubuntugeek.com/speed-up-f...b-browser.html
Keep in mind that some of these tutorials are outdated and the settings they suggest might not have any effect on the Firefox version you are using. To check if a particular setting is still valid, what it does and the recommended settings, you can browse the Mozilla Knowledge Base.
Here are some of the most popular settings that you can change:
netwok.prefetch-next 
network.http.pipelining 
network.http.pipelining.maxrequests 
network.http.proxy.pipelining 
network.dns.disableIPv6 
nglayout.initialpaint.delay 
browser.cache.memory.capacity 
ipv6
Network became slow due to the unsupported ipv6 protocol, so disabling ipv6 could help. 
To disable ipv6 on Firefox Preferences, set the network.dns.disableIPv6 to true.
1. Type about:config in the address bar, press Enter.
2. Find network.dns.disableIPv6 in the list.
3. Right-click -> Toggle.
4. Restart your Mozilla application and try again. 
You can also disable ipv6 on the system. 
How To Disable IPV6 in Ubuntu 9.04 ?
Flash Optimization
Flash has been a problem for a long time and is works really bad on Jaunty. When I play an embedded video, the CPU usage increases a lot. The amount of stress on the CPU depends on several factors, but when measuring the CPU usage while playing the same video file with gnome-mplayer and embedded in the site, the difference is huge. For example, this video, which uses h264 codec from YouTube, raises the CPU usage to about 45% of it's capacity. The same video only uses 9% of my CPU if downloaded and played with gnome-mplayer.
It's probably not a Firefox issue, since most browsers I tested displayed the same problems, including Chromium. But there is definitely something wrong (see and vote for bug fix). Unfortunately, there is no magical fix, but you can try a few things below. 
Quote:
Note: For flash 64bit visit http://news.softpedia.com/news/How-t...10-98076.shtml
Removing Conflicting Plugins
Ubuntu comes with swfdec plug-in, but it doesn't work on several sites. Installing the version from Adobe might solve this problem and improve performance. 
To remove other flash plug-ins and install only the one from Adobe open "Applications >> Accessories >> Terminal", then paste (CTRL+SHIFT+V) the code below in the terminal window and hit enter:
Code:
sudo apt-get remove swfdec-mozilla  sudo apt-get remove mozilla-plugin-gnash  sudo apt-get remove adobe-flashplugin  sudo apt-get remove flashplugin-nonfree  sudo apt-get install flashplugin-nonfree

Flash Tweaks
Some people reported improvements doing this (original source):
Code:
sudo mkdir /etc/adobe  echo "OverrideGPUValidation=true" >~/mms.cfg  sudo mv ~/mms.cfg /etc/adobe/

Compiz, Xorg and Graphics Tweaks
Some modifications to the xorg.conf file might improve overall performance, including Firefox and Flash. Some of this might not apply to your graphics card. Intel graphic cards users check the Jaunty Intel Graphics Performance Guide.
First make sure you have the proprietary graphics card driver installed. Go to "System >> Administration >> Hardware Drivers" and enable the corresponding driver.
To edit the xorg file run this:
Code:
gksudo gedit /etc/X11/xorg.conf

Then add the following lines:
Code:
Section "DRI"   Mode 0666  EndSection    Section "Extensions"   Option "Composite" "Enable"  EndSection

These will enable direct rendering and compositing. I don't know exactly what they do, but I had a huge flash performance boost after this, Firefox is much more responsive and fast and the system is more responsive too. See discussion here.
Compiz users might get considerable flash performance improvement in full screen mode by disabling the option Unredirect Fullscreen Windows that can be found under "System >> Preferences >> CompizConfig Settings Manager >> General Options >> General".
Blocking Flash Content
Using NoScript or FlashBlock extensions can also help. They are not solutions, but prevent flash content from loading on pages that you don't need, specially if they are banners and other useless stuff.
Flash Replacements
Considering the current status of flash in Jaunty I'm moving towards a replacement solution instead of a fixing solution, particularly in regard to streaming videos. There are a few alternatives for playing this type of flash content. Unfortunately, most solutions compromise usability or do not work on every web site.
The easiest solution is to download the content, using the built in tools of Firefox or a download extension, then playing with your favorite media player. I recommend Video Download Helper. But unless I want to keep the video for later viewing, I find this annoying. 
For better integration with video players, there is the Media Player Connectivity extension, which allows you to load the video with your favorite media player by simply clicking on it. The main problem of this extension is that you have to click on every flash content you want to see embedded, which is very annoying on sites with flash interfaces.
You can also use a modified version of Netvideohunter extension to automatically detect videos on a page and play them with mplayer. See discussion here.
The nicest solution I have found so far is a Greasemonkey script, that replaces the embedded plash player with mplayer. This one has a nice set of tools and replace the YouTube video player seamlessly, using my gecko-mediaplayer plugin (image below), but it just works on YouTube. There are other similar scripts for other web sites that you can download here.

Running Profiles from RAM
As already explained in the Database Optimization section, Firefox stores lots of information on sqlite databases, compromising performance when disk access is high.
This section provides a script, that allows to load the entire Firefox profile into RAM, thus avoiding excessive disk access during sqlite operations and thus increasing performance considerably.
Quote:
Note: the script is based on the tutorial Howto; Firefox profile in RAM for increased speed and stability, but instead of loading a single profile permanently, it allows you to choose which profile to load, before starting Firefox. Additionally, it doesn't require any manual editing if you are using the official Ubuntu Firefox.
Quote:
Warning: this script is currently under testing, so be aware that you might loose Firefox profile data or experience unreported strange behaviors. Additionally, since the profile is loaded into RAM, any system crashes or power failures may result in loss of profile data. Nevertheless, the script creates a backup of your profile before sending it to RAM, synchronizes the profile changes in regular intervals during operation and before sending the profile back to the disk.
First we need to make sure we have the necessary dependencies. Most of this programs are installed by default, but just in case, run the following command:
Code:
sudo apt-get install sqlite3 zenity rsync

Run this command to create a new file called ramprofile.sh, in your home directory:
Code:
gedit ramprofile.sh

Then paste the code below and save it:
Code:
#!/bin/bash    TODAY=$( date +%Y%m%d )  NOW=$( date +%H:%M )    #test if fstab already have a firefox entry  if test -z "$(cat /etc/fstab | grep -F "firefox" )"  then      #kill firefox to prevent errors      killall firefox        zenity --info --text "Make sure Firefox is closed before proceeding" &&        #create a profile backup in your home folder      tar cvf ${HOME}/firefoxprofiles-${TODAY}-${NOW}.tar ${HOME}/.mozilla/firefox /etc/fstab &        #grab profile list and create a new script to allow profile selection (I know could be more elegant)      echo "#!/bin/bash" > ${HOME}/.mozilla/firefox/profileselect.sh      echo "" >> ${HOME}/.mozilla/firefox/profileselect.sh      echo 'PROFILE=$(zenity --list --height=300  --width=300 --text "Firefox Profiles" --radiolist  --column "Select" --column "Profile" \' >> ${HOME}/.mozilla/firefox/profileselect.sh      cat $HOME/.mozilla/firefox/profiles.ini | sed "/Path/!d" | sed "s/Path=//g" | sed "s/.*/1 \'&/g" | sed "s/.*/&\' \\\/g" >> ${HOME}/.mozilla/firefox/profileselect.sh      echo ")" >> ${HOME}/.mozilla/firefox/profileselect.sh      echo 'echo ${PROFILE} > ${HOME}/.mozilla/firefox/profile.txt' >> ${HOME}/.mozilla/firefox/profileselect.sh      chmod +x ${HOME}/.mozilla/firefox/profileselect.sh        #run the script to select the profile      ${HOME}/.mozilla/firefox/profileselect.sh        #Input variables      PROFILE=$(cat $HOME/.mozilla/firefox/profile.txt)        RAM=$(zenity --list --height=400  --width=150 --text "How much Mb of RAM to allocate? Your cache size is 20Mb" --radiolist  --column "Select" --column "Memory to be allocated for profile" \      1 '64M' \      2 '96M' \      3 '128M' \      4 '160M' \      5 '192M' \      6 '224M' \      7 '256M' \      8 '288M' \      9 '320M' )        SYNC=$(zenity --list --height=400  --width=150 --text "Profile synchronization frequency in minutes?" --radiolist  --column "Select" --column "Frequency" \      1 '05' \      2 '10' \      3 '15' \      4 '20' \      5 '25' \      6 '30' \      7 '35' \      8 '40' \      9 '45' \      0 '50' \      1 '55' )         #backup and modify fstab based on selected variables      sudo cp /etc/fstab /etc/fstab.bak      cat /etc/fstab.bak | sed -e '/firefox.*/d' > ${HOME}/.mozilla/firefox/fstab      echo "firefox ${HOME}/.mozilla/firefox/${PROFILE} tmpfs size=${RAM},noauto,user,exec,uid=1000,gid=1000 0 0" >> ${HOME}/.mozilla/firefox/fstab      sudo mv ${HOME}/.mozilla/firefox/fstab /etc/fstab        #move the original profile to ramprofile      mv ${HOME}/.mozilla/firefox/${PROFILE} ${HOME}/.mozilla/firefox/ramprofile        #modify firefox preferences      cat ${HOME}/.mozilla/firefox/ramprofile/prefs.js | sed -e "/user_pref(\"browser.cache.disk.enable.*/d" | sed -e "s/user_pref(\"browser.cache.disk.capacity.*/user_pref(\"browser.cache.disk.capacity\", 20000);/g" | sed -e "/user_pref(\"browser.safebrowsing.enabled.*/d" | sed -e "/user_pref(\"browser.safebrowsing.malware.enabled.*/d" > ${HOME}/.mozilla/firefox/prefs.js      echo "user_pref(\"browser.safebrowsing.enabled\", false);" >> ${HOME}/.mozilla/firefox/prefs.js      echo "user_pref(\"browser.safebrowsing.malware.enabled\", false);" >> ${HOME}/.mozilla/firefox/prefs.js      echo "user_pref(\"browser.cache.disk.enable\", true);" >> ${HOME}/.mozilla/firefox/prefs.js      cat ${HOME}/.mozilla/firefox/prefs.js > ${HOME}/.mozilla/firefox/ramprofile/prefs.js      rm -f ${HOME}/.mozilla/firefox/prefs.js        #create empty profile folder      mkdir ${HOME}/.mozilla/firefox/${PROFILE}        #send the profile to RAM      mount "${HOME}/.mozilla/firefox/${PROFILE}"        #copy original profile contents to RAM profile      rsync -av -p -o -g ${HOME}/.mozilla/firefox/ramprofile/ ${HOME}/.mozilla/firefox/${PROFILE}/        #create cron job      echo "" > ${HOME}/.mozilla/firefox/.change.cron      echo "USER=$USER" >> ${HOME}/.mozilla/firefox/.change.cron      echo "HOME=$HOME" >> ${HOME}/.mozilla/firefox/.change.cron      echo "SHELL=/bin/bash" >> ${HOME}/.mozilla/firefox/.change.cron      echo "PATH=/sbin:/bin:/usr/sbin:/usr/bin" >> ${HOME}/.mozilla/firefox/.change.cron      echo "DISPLAY=:0.0" >> ${HOME}/.mozilla/firefox/.change.cron      echo "MAILTO=$USER" >> ${HOME}/.mozilla/firefox/.change.cron      echo "" >> ${HOME}/.mozilla/firefox/.change.cron      echo "0-59/${SYNC} * * * * rsync -av -p -o -g --delete ${HOME}/.mozilla/firefox/${PROFILE}/ ${HOME}/.mozilla/firefox/ramprofile/" >> ${HOME}/.mozilla/firefox/.change.cron      crontab ${HOME}/.mozilla/firefox/.change.cron        #launch firefox      LAUNCH=$( echo "${PROFILE}" | sed 's/.*\.//g' )      zenity --info --text "Firefox profile ${LAUNCH} is loaded into RAM. Firefox launch automatically now. Don't forget to unload the profile after using Firefox!" &&      firefox -P ${LAUNCH} &  else      #alert in case fstab already have a firefox entry      zenity --info --text "The fstab already has a Firefox entry. You should try to unload the profile from RAM first."  fi  exit

Then run this command to make it executable:
Code:
chmod +x $HOME/ramprofile.sh

Quote:
Note: the script only works if you have at least one profile in the folder ~/.mozilla/firefox/. If you are running an alternative version of Firefox, like some from the next section, then make sure your profiles are not stored somewhere else. For example, Shiretoko stores profiles under ~/.mozilla/firefox-3.5. If this is the case, then make a symlink to your profile folder inside the ~/.mozilla/ and rename it to firefox. Additionally, the script also launches Firefox automatically, so if you use a custom launcher, you might need to edit the script to satisfy the correct Firefox launcher path.
To use it, open a Terminal and run this command:
Code:
ramprofile.sh

The commands explanations are included in the script as comments. I strongly recommend you read them , so you can understand what they do. Nevertheless, here is the basic functionality of it:
The script first detect your existing profiles and prompt you to choose which one you want to load into RAM. You can load only one profile at a time. 
Then it asks how much memory you want to allocate for the profile in RAM 
Then asks the interval you want to synchronize the profile with a copy in the disk, so you can keep any changes after unloading the profile from RAM. 
Then it saves a tar backup of your profile inside ~/.mozilla/firefox/ just to be safe in case something goes wrong with the synchronized copy during operation. This backup is named using the profile name, date and time of creation. It also includes a backup of your /etc/fstab. 
Then it creates a temporary /etc/fstab.bak to allow reverting the changes after unloading the profile from RAM. 
Then it changes the necessary preferences in Firefox prefs.js file (please not that safe browsing feature is disabled) 
Then it moves the content from your profile to a temporary folder ~/.mozilla/firefox/ramprofile, mount the profile into the RAM, the copy the contents from ~/.mozilla/firefox/ramprofile into it. 
Then it creates a cron job to allow synchronization between ~/.mozilla/firefox/ramprofile and your profile in RAM. (this might override personal cron jobs) 
Then it launches Firefox using the selected profile 
Quote:
Warning: You should always unload the profile from RAM before logging off or rebooting, otherwise the profile content might be lost and the profile might not be unmounted from RAM.
The next script is used to unload the profile after using Firefox, after a system crash or after rebooting without unloading the profile first.
Run this command to create a new file called ramprofile.sh, in your home directory:
Code:
gedit restoreprofile.sh

Then paste the code below and save it:
Code:
#!/bin/bash        #close firefox      killall firefox        zenity --info --text "Make sure Firefox is closed before proceeding" &&        #Input variables      PROFILE=$(cat $HOME/.mozilla/firefox/profile.txt)    if test -z "$(mount | grep -F "${HOME}/.mozilla/firefox/${PROFILE}" )"  then      zenity --info --text "The profile is not mounted. The script will check if the fstab has Firefox entries..." &&      if test -z "$(cat /etc/fstab | grep -F "firefox" )"      then          zenity --info --text "The fastab has no Firefox entries. It seems all necessary steps have been taken to uload the profile from RAM, but you should check your profile folders to see if everthing is in place."      else          zenity --info --text "The script will try to restore the fstab, remove temporary files, clear cron jobs and restore your profile, but you should check your profile folders to see if everthing is in place."          #remove cron jobs          echo "" > ${HOME}/.mozilla/firefox/.change.cron          crontab ${HOME}/.mozilla/firefox/.change.cron            #delete temporary files, restore the profile to disk and restore fstab          rm -fr ${HOME}/.mozilla/firefox/${PROFILE}          rm -f ${HOME}/.mozilla/firefox/.change.cron          rm -f ${HOME}/.mozilla/firefox/profile.txt          rm -f ${HOME}/.mozilla/firefox/profileselect.sh          mv ${HOME}/.mozilla/firefox/ramprofile ${HOME}/.mozilla/firefox/${PROFILE}          sudo mv /etc/fstab.bak /etc/fstab          zenity --info --text "Profile successfuly unmounted. You might need to restore a profile from a backup."      fi  else      if test -z "$(cat /etc/fstab | grep -F "firefox" )"      then         zenity --info --text "The fastab has no Firefox entries, but the profile is mounted. The script will try to fix this..."           #backup and modify fstab based on selected variables         sudo cp /etc/fstab /etc/fstab.bak         cat /etc/fstab > ${HOME}/.mozilla/firefox/fstab         echo "firefox ${HOME}/.mozilla/firefox/${PROFILE} tmpfs size=200M,noauto,user,exec,uid=1000,gid=1000 0 0" >> ${HOME}/.mozilla/firefox/fstab         sudo mv ${HOME}/.mozilla/firefox/fstab /etc/fstab           #remove the profile from RAM         umount "${HOME}/.mozilla/firefox/${PROFILE}"           #remove cron jobs         echo "" > ${HOME}/.mozilla/firefox/.change.cron         crontab ${HOME}/.mozilla/firefox/.change.cron           #delete temporary files, restore the profile to disk and restore fstab         rm -fr ${HOME}/.mozilla/firefox/${PROFILE}         rm -f ${HOME}/.mozilla/firefox/.change.cron         rm -f ${HOME}/.mozilla/firefox/profile.txt         rm -f ${HOME}/.mozilla/firefox/profileselect.sh         mv ${HOME}/.mozilla/firefox/ramprofile ${HOME}/.mozilla/firefox/${PROFILE}         sudo mv /etc/fstab.bak /etc/fstab           zenity --info --text "Profile successfuly unmounted. You might need to restore a profile from a backup."        else          #remove cron jobs          echo "" > ${HOME}/.mozilla/firefox/.change.cron          crontab ${HOME}/.mozilla/firefox/.change.cron            #sync the profile from RAM to disk          rsync -av -p -o -g --delete ${HOME}/.mozilla/firefox/${PROFILE}/ ${HOME}/.mozilla/firefox/ramprofile/                #remove the profile from RAM          umount "${HOME}/.mozilla/firefox/${PROFILE}"            #delete temporary files, restore the profile to disk and restore fstab          rm -fr ${HOME}/.mozilla/firefox/${PROFILE}          rm -f ${HOME}/.mozilla/firefox/.change.cron          rm -f ${HOME}/.mozilla/firefox/profile.txt          rm -f ${HOME}/.mozilla/firefox/profileselect.sh          mv ${HOME}/.mozilla/firefox/ramprofile ${HOME}/.mozilla/firefox/${PROFILE}          sudo mv /etc/fstab.bak /etc/fstab            #optimize profile databases          find ${HOME}/.mozilla/firefox/${PROFILE} \( -name "*.sqlite" \) -exec sqlite3  {} "vacuum" \;            zenity --info --text "Profile ${PROFILE} was successfully unloaded."      fi  fi  exit

Then run this command to make it executable:
Code:
chmod +x $HOME/restoreprofile.sh

To use it, open a Terminal and run this command:
Code:
restoreprofile.sh

Here is the basic functionality of this script:
It checks if the profile is mounted and if the fstab has firefox entries. Then, depending on the results.. 
Unmount and restore a mounted profile without fstab entry, trying to preserve the profile files from last sync, clears the cron jobs and delete temporary files 
Unmount the mounted profile, clears the cron jobs, restore the profile from RAM to disk, delete temporary files, restore the fstab and perform sqlite database optimization 
The next script is used to synchronize the profile while using Firefox. The first script already provides a cron job to do that, but in some circumstances you might want to synchronize it manually.
Run this command to create a new file called syncprofile.sh, in your home directory:
Code:
gedit syncprofile.sh

Then paste the code below and save it:
Code:
#!/bin/bash        #Input variables      PROFILE=$(cat $HOME/.mozilla/firefox/profile.txt)    if test -z "$(mount | grep -F "${HOME}/.mozilla/firefox/${PROFILE}" )"  then      zenity --info --text "The profile is not mounted."  else      #sync the profile from RAM to disk      rsync -av -p -o -g --delete ${HOME}/.mozilla/firefox/${PROFILE}/ ${HOME}/.mozilla/firefox/ramprofile/      zenity --info --text "Profile ${PROFILE} in RAM was successfully synchronized with disk copy."  fi  exit

To use it, open a Terminal and run this command:
Code:
restoreprofile.sh

Installing Other Versions
If you don't like to wait until new Firefox releases hit the official repositories, you can install fresh final releases from Mozilla, development versions or alternative browsers build upon Firefox code. You can find easy installation methods below.
Quote:
Warning: If you want a painless Firefox upgrade, then wait until the update manager offers you the new version. Nevertheless, if you want to install new releases before the Ubuntu developers test them and make them available through the official repository, then you can use one of the methods described in this section. But please don't use all of them, otherwise you will have multiple versions of Firefox and might experience some issues. For a more detailed explanation of the differences between each method please refer to "Method Comparison" at the end of this section. I personally prefer methods #1 and #2, being the second the most easy to maintain and to perform future updates of stable releases. See which method is the most popular in the thread What versions of Firefox are Ubuntu Forums members using?
64-bit: If you want the 64-bit version of Firefox than you need to use installation method #3.
Special Note: if you are interested in Firefox 3.5, then you don't need to add extra PPA repositories anymore, because the final version is already available in the Universe repository of Ubuntu Jaunty Jackalope 9.04, although it will be branded Shiretoko, not Firefox. If you don't like the Shiretoko name and want the Firefox logo, then proceed to methods #1 or #2 of this section, to install Firefox 3.5 official release from Mozilla. To install Shiretoko 3.5 final release, scroll down to method #4.
Installation Methods
1 - Manual installation of fresh final releases from Mozilla
Quote:
Note: I recommend reading the original article at http://www.psychocats.net/ubuntu/firefox, specially if you already installed previous versions on the /opt directory. Nevertheless, if this is the first time you install Firefox manually, then you can follow the simplified instructions below.
For manual installation of fresh released final versions of Firefox, you can download the current Mozilla release version from Get Firefox site, saving it on your home directory, then run the commands below:
Code:
cp -R ~/.mozilla ~/.mozilla.backup  sudo tar -jxvf firefox-*.tar.bz2 -C /opt  rm firefox-*.tar.bz2  sudo mv /opt/firefox/plugins /opt/firefox/plugins.backup  sudo ln -s /usr/lib/xulrunner-addons/plugins /opt/firefox/plugins  sudo ln -s /opt/firefox/firefox /usr/local/bin/firefox

Reverting Changes
To revert these changes and use Firefox 3.0.x again, run the following command:
Code:
sudo rm /usr/local/bin/firefox && sudo rm -r /opt/firefox

2 - Automatic installation of fresh final releases from Mozilla
You can install fresh final releases and keep updating them using the Ubuntuzilla. It's easy to install this way and also to remove it. 
3 - Installation of development versions
You can install development versions of Firefox using the semi-official ubuntu-mozilla-security or ubuntu-mozilla-daily PPA repositories. Follow the instructions on the link below:
https://help.ubuntu.com/community/FirefoxNewVersion
Quote:
Warning: these repositories do not stop at the same release version that can be downloaded from Mozilla web site, so you will continue to get updates, including unstable Alpha, Beta and RC releases.
Quote:
Warning: Firefox development versions have different names and logos than the version available in the official repositories. So, don't be scared if you find a browser named Shiretoko or Minefield after installation from these instructions. This is normal and they are not different from Firefox. Additionally, when you install a development release, it is installed side-by-side with the official Ubuntu Firefox, so you need to launch it separately from the Internet menu.
4 - Installing Alternative Browsers
4.1 - SHIRETOKO
Shiretoko 3.5 final release is available in the Universe repositories so you can install it clicking here or through the Add/Remove manager or using the command below:
Code:
sudo apt-get install firefox-3.5

Shiretoko is Firefox without the branding, which means it won't display Firefox name or logo. Nevertheless is the same software. This package is maintained by the community, not the Ubuntu developers. When you search for Shiretoko in the Add/Menu browser it says it is a Beta version. But don't worry, it has been already updated to final release.
4.2 - SWIFTFOX
Swiftfox is an optimized build of Mozilla Firefox. Swiftfox has builds for both AMD and Intel processors and is based on the most cutting edge Firefox source code available. It is installed side-by-side with Firefox, but shares the user profiles.
To install follow the instructions at http://getswiftfox.com/deb.htm
4.3 - SWIFTWEASEL
Swiftweasel is a build of Mozilla Firefox source code, which uses non-trademarked graphics and logos. It is optimized for several architectures, and is available for the Linux platform only (original article). The main difference when compared to Swiftfox is that Swiftweasel is free and open source software, while Swiftfox's binaries are proprietary.
To install, first download the tar.gz file for your architecture at http://sourceforge.net/projects/swiftweasel/files/, saving it in your home directory. Then run the following commands in the terminal:
Code:
sudo tar -xvf swiftweasel-3.5*ubuntu.tar.gz -C /opt  rm swiftweasel-3.5*ubuntu.tar.gz  sudo ln -s /usr/lib/xulrunner-addons/plugins /opt/swiftweasel/plugins  sudo ln -s /opt/swiftweasel/swiftweasel /usr/local/bin/firefox

Then just click the firefox launcher and it will launch Swiftweasel instead. To uninstall and revert all changes, run the following command:
Code:
sudo rm /usr/local/bin/firefox && sudo rm -r /opt/swiftweasel

Quote:
Note: Swiftweasel profile is saved under ~/.sw35/swiftweasel
Method Comparison
All methods install another version of Firefox on a separate location and can be used side-by-side with the official Ubuntu Firefox of your distribution.
#1 - this method is easy to perform, gives you total control of which version you will install and it gives you only official Mozilla releases, with Firefox branding (name and logo). Additionally, it uses the same Firefox profiles as the official Ubuntu version and updates your Firefox launchers automatically. It does not provide new version checking and download. You have to download new versions manually, remove the old version before updating with a new one and perform the installation commands for each new install.
#2 - essentially the same as the method #1, but provides a way to check for updates from Mozilla releases siteand install them automatically. Also provides an automated method of removal. Initial setup is not as easy as the manual installation, but is not complicated at all, since the automated script is provided as a deb install. It requires a single command to perform installation/removal of Firefox and other Mozilla applications.
#3 - more complicated to setup, since you need to configure additional PPA repositories. Depending on the PPA selected, you will get Firefox updates that are currently undergoing security testing or updates that are currently under development. This is not recommended if you want only stable releases, since you will probably get pre-alpha, alpha and beta releases as well. Additionally, all versions will not be Firefox branded. They use the development codenames, like Shiretoko or Minefield, and a default blue logo. These versions are not only installed side-by-side with Firefox 3.5, but also have their own Firefox profile folders, which might be complicated to maintain if you go back to stable official releases or when you upgrade Ubuntu. Versions installed by this method also have their own menu launchers, available through the "Applications >> Internet" menu.
#4.1 - this method allows you to install unlicensed development versions of Firefox like the method #3 (actually this method is included in the method #3 procedures), but updates are performed only after being proposed by the universe repository maintainers and approved to enter this repository. You won't get regular updates like using the PPA repositories, but it's easier to configure and more stable. For instance, when Jaunty was released, the version installed by this method was Shiretoko 3.5 beta4pre, then it as updated to rc2 a couple of weeks before the official release of Firefox 3.5 and was updated to the final release less then a week after Mozilla. This method also creates new launchers. Your current Firefox profiles are automatically copied and put on a separate folder under ~/.mozilla
#4.2 - this method allows you to install cutting-edge versions of Firefox, optimized for your processor and branded as Swiftfox. It can be installed by using deb files or the Swiftfox repositories. Depending on which deb file you get or which updates you accept from the repositories, you might also get development versions. For instance, by the time of writing, Swiftfox version being provided was 3.5rc3-1. The major advantage of this method is the availability of versions optimized for your processor, which might result in a considerable performance boost. In the other hand, the major disadvantage is that these versions are non-free and the source code is not available. Unlike Shiretoko, Swiftfox versions uses the same profiles as your official Ubuntu Firefox installation, but also creates it's own launchers.
#4.3 - this method is essentially the same as 4.2, but Swiftweasel is free and open source software. It is distinct from Swiftfox in that Swiftweasel is completely free while Swiftfox's binaries are proprietary.
Extension Compatibility
When you install a new version directly from Mozilla or through the other methods above, some of your extensions won't work, because they are dependent on the Firefox version. But the extension compatibility check can be disabled by setting the preference extensions.checkCompatibility to false. Some extensions might work this way, because they don't have anything in their code that could break on the new Firefox version, they just haven't been tested yet and the authors didn't change the version compatibility in the installation file. So when you disable extension check, they work as usual. Nevertheless, some extensions might have incompatible code, so use it at you own risk. 
You can also use the Nightly Tester Tools extension to override compatibility of other extensions.
Completely disabling the compatibility check
Other Optimizations
General System Optimization
This is not related directly to Firefox, but it is part of my optimizations that improved all browsers performance, including flash performance, so I decided to include the link here.
http://ubuntuforums.org/showthread.php?t=1152095
Troubleshooting
Several Firefox problems are related to corrupted profiles and can be easily fixed by restoring a profile backup (see Backup section), by deleting the corrupted profile or deleting specific files inside the profile. Usually, there is no need to re-install Firefox.
Quote:
Note: Several posts on these forums recommends moving, renaming or deleting ~/.mozilla folder to solve Firefox issues. While this will certainly remove any corrupted Firefox profiles and thus solve many common issues, you should consider that the ~/.mozilla folder is also the place where other Mozilla applications might store their profiles (Sunbird, etc), so removing this folder will also remove their settings. 
Firefox profiles are stored under ~/.mozilla/firefox or ~/.mozilla/firefox-x.y folders, where x.y is the Firefox version. So if you need to remove a Firefox profile to fix a problem, then remove ~/.mozilla/firefox or ~/.mozilla/firefox-x.y not ~/.mozilla. 
Nevertheless, there also no reason to delete the entire profile if you can pinpoint the culprit inside it. Most common Firefox issues can be traced back to a single profile file. So, if you can avoid removing the entire profile, you will be able to preserve other settings like extensions, themes, bookmarks, cookies and passwords.
You can find some common symptoms and possible solutions below. Keep in mind that your Firefox might display one or more of these symptoms and they are not mutually exclusive.
Symptoms:
Firefox doesn't start through regular command/menu but starts using "sudo firefox". 
Quote:
Note: Please DO NOT use sudo firefox. If you really need to run Firefox with administrative rights for whatever reasons, then use gksudo firefox instead. When you use gksudo it's starts Firefox with administrative rights, but uses the root Firefox profiles, while sudo uses the user profiles, thus messing with the permission and preventing regular users from loading their profiles correctly. More info athttp://www.psychocats.net/ubuntu/graphicalsudo
Solution [FOT001]:
Check the permissions of ~/.mozilla/ and ~/.mozilla/firefox/ folders. If these folders are owned by root, then it could prevent Firefox from saving settings or even running.
To change the permission back to you, run this command:
Code:
sudo chown -R $USER:$USER ~/.mozilla

If that doesn't work, then you might need to create a new profile or rename/move/delete ~/.mozilla/firefox/, so it will automatically recreate your profile next time you start it. Please refer to Backup section before doing this.
Symptoms:
Firefox covers the entire screen and you can't minimize or close it. 
Addons page is blank. 
Some toolbars are missing. 
Solution [FOT002]:
Simply hitting the F11 key twice should bring Firefox to normal maximized state. To fix this problem permanently, delete the file localstore.rdf in your profile and restart Firefox.
Quote:
http://kb.mozillazine.org/Localstore.rdf
localstore.rdf stores customized data on the interface, such as toolbar customizations, window positions and sizes, and tree sort orders. In Firefox 1.5 and above, the safe mode option "Reset toolbars and controls" clears this file.
Symptoms:
All bookmarks have disappeared and backups cannot be restored. 
Bookmarks changes are reverted after restart 
Back and forward buttons are greyed out or doesn't work 
The Home Page is blank no matter what you put in the settings. 
Address bar does not work. 
Browser history does not work. 
Solution [FOT003]:
Delete the file places.sqlite from the profile folder. 
Quote:
http://kb.mozillazine.org/Places.sqlite
The file "places.sqlite" stores the annotations, bookmarks, favorite icons, input history, keywords, and browsing history (a record of visited pages).
Symptoms:
Can't play streaming flash videos 
Flash videos display only a symbol and won't start 
Solution [FOT004]:
Some video issues are caused by conflicting plug-ins. It's not a good idea to have multiple plug-ins for the same type of content.
To remove conflicting flash plug-ins and install only the one from Adobe open "Applications >> Accessories >> Terminal", then paste (CTRL+SHIFT+V) the code below in the terminal window and hit enter:
Code:
sudo apt-get remove swfdec-mozilla  sudo apt-get remove mozilla-plugin-gnash  sudo apt-get remove adobe-flashplugin  sudo apt-get remove flashplugin-nonfree  sudo apt-get install flashplugin-nonfree

Quote:
Note: if you have only the plug-in from Adobe and can't watch videos only from certain web sites, then check if you have an extension like AdBlock. It might be blocking the content form the video. Replacing Adblock with AdBlock Plus might solve the problem. See discussion here.
Symptoms:
Web sites keeps loading but never show up 
Firefox can't connect to any sites, but other browsers work 
Firefox can connect to sites only using the IP number 
Connections settings are reset after restart 
Solution [FOT005]:
Make sure your connection settings are correct (e.g., Tools -> Options -> Advanced -> Network / Connection -> Settings). If the settings reset after restart, then delete the file user.js from the profile folder, to reset proxy settings.
Additionally, disable ipv6 on Firefox Preferences, by setting the network.dns.disableIPv6 preference to true.
1. Type about:config in the address bar, press Enter.
2. Find network.dns.disableIPv6 in the list.
3. Right-click -> Toggle.
4. Restart your Mozilla application and try again. 
Quote:
http://kb.mozillazine.org/Error_load...aving_problems
To resolve this problem, open the profile folder and look for a user.js file. If found, either remove the user.js file or edit it to remove any "proxy" settings it may contain as outlined here, then reset the connection settings.
Symptoms:
No text on some webpages 
Text on web pages is too small 
Solution [FOT006]:
Open "Edit >> Preferences >> Content" and click the "Advanced" button in the "Fonts & Colors" section, then edit the font size and color. Untick the option "Allow pages to use their own fonts, instead of my selections above".
Symptoms:
Some images are displayed with weird colors 
Solution [FOT007]:
This is due to color management feature, which allows to correct image colors based on embedded color profiles. You could disable color management, but the best way is to enable color management for tagged graphics only, which means all images will display correctly, even if they don't have color profiles.
1. Type about:config in the address bar, press Enter.
2. Find gfx.color_management.mode in the list.
3. Right-click -> Modify.
4. Set the value to 2. 
5. Restart Firefox
If you still experience issues, then disable color management entirely, by setting the value above to 0.
If you also have gfx.color_management.enabled properties, try to reset it or change it to true. This preference should not be present on Firefox 3.5.
Quote:
http://kb.mozillazine.org/Gfx.color_management.mode
Color management allows images and colors to be displayed consistently across a variety of devices. Mozilla recognizes embedded ICC profiles in image files and uses a local color profile to perform the color adjustments. This preference determines if Mozilla should make these adjustments.
Symptoms:
Firefox 3.5 crash when viewing YoutTube on fullscreen 
Solution [FOT008]:
Quote:
Note: thanks to VCoolio for this solution. See original discussion here.
You need to add a line to the firefox launching script, to load the flash plugin before Firefox.
Code:
export LD_PRELOAD=/usr/lib/libGL.so.1

Add the line above just after the line starting with:
Code:
moz_libdir=/*

or
Code:
LIBDIR=/*

The location of the script varies according to the method of installation of Firefox 3.5, described in the "Install Other Versions" section:
Method #1 (Psychocats): /opt/firefox/firefox 
Method #2 (Ubuntuzilla): /opt/firefox/firefox 
Method #3 (Repositories): /usr/lib/firefox-3.5/firefox.sh 
Method #4.1 (Shiretoko): /usr/lib/firefox-3.5/firefox.sh 
Compiled Firefox: /usr/local/lib/firefox-3.5/firefox 
Symptoms:
No sound on YouTube or Hulu videos 
Streaming video sound goes really fast sometimes 
Solution [FOT009]:
First make sure you don't have conflicting plugins by removing them. To remove conflicting flash plug-ins and install only the one from Adobe open "Applications >> Accessories >> Terminal", then paste (CTRL+SHIFT+V) the code below in the terminal window and hit enter:
Code:
sudo apt-get remove swfdec-mozilla  sudo apt-get remove mozilla-plugin-gnash  sudo apt-get remove adobe-flashplugin  sudo apt-get remove flashplugin-nonfree  sudo apt-get install flashplugin-nonfree

. 
Then go to "System >> Preferences >> Sound" and set "Music and Movies" to Alsa and check if it works. If changing sound settings doesn't work, then you can try to fix pulseaudio or remove it completely. 
To fix pulseaudio visit HOWTO: PulseAudio Fixes & System-Wide Equalizer Support. 
To remove pulseaudio and install esound follow this. Removing pulseaudio and installing esound should probably fix this and also gives better system performance. 
Quote:
Warning: when you remove pulseaudio or install esound, the package manager also removes the metapackage ubuntu-desktop. Don't worry, this file is used only for upgrades between Ubuntu releases. Just make sure you install it before upgrading. If you do clean installs between releases, then you don't need to worry about it. Nevertheless it is recommended to fix pulseaudio configuration instead of removing it.
For additional multimedia issues visit Comprehensive Multimedia & Video Howto
Symptoms:
Firefox becomes unresponsive (grey) frequently 
Firefox lock up with no apparent reason, even when left alone 
Solution [FOT010]:
Disable the safe browsing feature. To do that, go to "Edit >> Preferences >> Security", uncheck "Block reported attack sites" and "Block reported web forgeries".
Quote:
Note: I strongly recommend using NoScript extension to block malicious scripts and AdBlock Plus to block third-party ad content, which might have malicious code.
Quote:
Note: This solution was suggested by "powertower". See original discussion here.
Also visit http://kb.mozillazine.org/Firefox_hangs for additional solutions and troubleshooting.
Compiling Firefox
What does compiling means?
Quote:
From: http://en.wikipedia.org/wiki/Compiling
A compiler is a computer program (or set of programs) that transforms source code written in a computer language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program.
Is there any advantages of compiling Firefox from source instead of using the official version provided by the Ubuntu repositories?
Yes. First, you don't have to wait for the update of the repositories when a new version is released. You can just download Firefox source code from Mozilla site and compile it yourself. But the most important reason, in my opinion, is that you can optimize Firefox to run on your machine, using especial settings that makes it "talk" better with your specific CPU. My current Firefox performance was improved by 30% after compiling it for my processor specs.
Is it complicated to compile Firefox?
Compiling Firefox is not as complicated as it sounds. Nevertheless, it requires some reading and configuration if you want to get the most of the optimization features (I should give the proper credit to TheLions for helping withmy first Firefox compilation).
Quote:
Note: You should read the Mozilla Build Documentation before compiling, but if you want the easy way, just follow the Procedures below.
Procedures
Quote:
NOTE: Don't forget to replace y.z.x and x.y.z in the codes provided here with the corresponding firefox and mozilla versions you are compiling!
First we need to install the essential packages required for compiling Firefox:
Code:
sudo apt-get install build-essential checkinstall  sudo apt-get build-dep firefox  sudo apt-get install mercurial libasound2-dev libcurl4-openssl-dev libnotify-dev

We also need to download the source code from Mozilla FTP site (Firefox 3.5). Save it in your home directory, then extract the package with this command:
Code:
tar -xjf firefox-*-source.tar.bz2

It will create a folder named ~/mozilla-x.y.z in your home directory, where x.y.z is the current release version. 
Open ~/mozilla-x.y.z and create an empty file and name it .mozconfig. This is the file where you will put the compilation options.
This is my .mozconfig file, optimized for Pentium4 3.06Ghz HT Prescott:
Code:
    . $topsrcdir/browser/config/mozconfig  export MOZILLA_OFFICIAL=1  export BUILD_OFFICIAL=1  mk_add_options MOZILLA_OFFICIAL=1  mk_add_options BUILD_OFFICIAL=1  mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@  ac_add_options --enable-official-branding      export CHOST="i686-pc-linux-gnu"      export CFLAGS="-O3 -march=prescott -pipe -fomit-frame-pointer"      export CXXFLAGS="-O3 -march=prescott -pipe -fomit-frame-pointer"      export CPPFLAGS="-O3 -march=prescott -pipe -fomit-frame-pointer"    ac_add_options --enable-application=browser  mk_add_options MOZ_CO_PROJECT=browser  ac_add_options --enable-optimize   ac_add_options --enable-default-toolkit=cairo-gtk2  ac_add_options --enable-xft  ac_add_options --enable-extensions=default  ac_add_options --enable-strip  ac_add_options --enable-install-strip  ac_add_options --enable-pango  ac_add_options --enable-svg  ac_add_options --enable-canvas  ac_add_options --disable-tests  ac_add_options --disable-accessibility  ac_add_options --disable-mochitest  ac_add_options --disable-debug  ac_add_options --disable-installer  ac_add_options --disable-crashreporter  ac_add_options --disable-parental-controls  ac_add_options --with-pthreads

Quote:
Note: Creating the .mozconfig is the most tricky part of the compiling process, since you need to use the correct settings according to your processor. This requires some reading. To understand what those options are and how to choose the required settings for your processor visit the tutorial below:
http://www.gentoo.org/doc/en/gcc-optimization.xml
Quote:
Note: Check the safe flags for Intel processors at http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
Quote:
Note: the settings above are good for me, but they remove some features I don't use, like crash report and parental control. For a list of mozconfig options visit https://developer.mozilla.org/en/Con..._Build_Options
After configuring the .mozconfig for your processor and preferences, save it and run the following commands:
Code:
cd ~/mozilla-x.y.z  make -f client.mk build

Firefox will be compiled with the options provided by the .mozconfig file. This process can take a while to finish. On my machine it took about an hour.
To install it, you need to cd into the obj directory, which is something like this:
Code:
cd ~/mozilla-x.y.z/obj-i686-pc-linux-gnu

The path in red varies.
Then simply run the following commands:
Code:
make  sudo checkinstall

Firefox will be installed to /usr/local/lib/firefox-y.z.x, where y.z.x is the version you installed and the Firefox launcher will automatically point to that location. If you still want to use Firefox 3.0.11 you can run the following command:
Code:
firefox-3.0

Additionally, a deb package will be created and saved under ~/mozilla-x.y.z, so you can install again in the future or on other machines.
Removal
If you didn't change the package parameters during the checkinstall configuration, then you will be able to remove the newly installed Firefox from the Synaptic Package Manager, by marking the package mozilla-x.y.z for removal. If you changed the parameters, then search for the corresponding package in Synaptic.
Manual Installation & Removal
Instead of using sudo checkinstall, you can simply use sudo make install for installing your compiled version of Firefox, but you won't be able to remove it using Synaptic. To remove it manually, run the following commands:
Code:
sudo rm -f /usr/local/bin/firefox  sudo rm -fr /usr/local/lib/firefox-y.z.x  sudo rm -fr /usr/local/lib/firefox-devel-y.z.x  sudo rm -fr /usr/local/share/idl/firefox-y.z.x  sudo rm -fr /usr/local/include/firefox-y.z.x

Quote:
Note: Don't forget to replace y.z.x and x.y.z with the corresponding firefox and mozilla versions.
Compiling with Profile-Guided Optimization
What is Profile-Guided Optimization (PGO)?
Quote:
From: http://en.wikipedia.org/wiki/Profile...d_optimization
Profile-guided optimization (PGO) is a compiler optimization technique in computer programming to improve program runtime performance. In contrast to traditional optimization techniques that solely use the source code, PGO uses the results of test runs of the instrumented program to optimize the final generated code.[1] The compiler is used to access data from a sample run of the program across a representative input set. The data indicates which areas of the program are executed more frequently, and which areas are executed less frequently. All optimizations benefit from profile-guided feedback because they are less reliant on heuristics when making compilation decisions.
Compiling Firefox with PGO enabled can improve performance considerably. I didn't noticed a huge performance boost using this method, maybe because I already used the processor optimization flags. Nevertheless, there is indeed at least some performance improvement.
To compile Firefox with PGO you have to add a couple of lines to the .mozconfig file and use a different command when building the code. Add the following lines in red to .mozconfig:
Code:
    . $topsrcdir/browser/config/mozconfig  export MOZILLA_OFFICIAL=1  export BUILD_OFFICIAL=1  mk_add_options MOZILLA_OFFICIAL=1  mk_add_options BUILD_OFFICIAL=1  mk_add_options PROFILE_GEN_SCRIPT='$(PYTHON) $(MOZ_OBJDIR)/_profile/pgo/profileserver.py'  mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@  ac_add_options --enable-official-branding      export CHOST="i686-pc-linux-gnu"      export CFLAGS="-O3 -march=prescott -pipe -fomit-frame-pointer"      export CXXFLAGS="-O3 -march=prescott -pipe -fomit-frame-pointer"      export CPPFLAGS="-O3 -march=prescott -pipe -fomit-frame-pointer"    ac_add_options --enable-application=browser  mk_add_options MOZ_CO_PROJECT=browser  ac_add_options --enable-optimize   ac_add_options --enable-profile-guided-optimization  ac_add_options --enable-default-toolkit=cairo-gtk2  ac_add_options --enable-xft  ac_add_options --enable-extensions=default  ac_add_options --enable-strip  ac_add_options --enable-install-strip  ac_add_options --enable-pango  ac_add_options --enable-svg  ac_add_options --enable-canvas  ac_add_options --disable-tests  ac_add_options --disable-accessibility  ac_add_options --disable-mochitest  ac_add_options --disable-debug  ac_add_options --disable-installer  ac_add_options --disable-crashreporter  ac_add_options --disable-parental-controls  ac_add_options --with-pthreads

Save the .mozconfig file and run the following commands:
Code:
cd ~/mozilla-x.y.z  make -f client.mk profiledbuild

Firefox will be compiled with the options provided by the .mozconfig file. This process can take a lot more time to finish. On my machine it took about 2 hours and 30 minutes.
To install it, follow the same installation procedure of the regular compilation process, using make and the checkinstall commands.
For more information: https://developer.mozilla.org/en/Bui...d_Optimization
That's it. Enjoy your super fast Firefox.

 原文地址 http://ubuntuforums.org/showthread.php?t=1193567

Cited from: http://blog.chinaunix.net/u/30686/showart_2055069.html


原创粉丝点击