« Open Library Catalog Data | Main | True Lies »

Dealing with huge bookmark files in Firefox

I noticed today that my Firefox bookmark file had bloated up from 259KB on November 28 to 477KB -- almost a half megabyte. The November size itself seemed much larger than I would have expected, but the size of the file today was of great concern to me. I knew that I hadn't been adding new bookmarks in Firefox at a rate that could account for this tremendous bloating in size. Furthermore, I shuddered to remember that about a year ago, my bookmarks has similarly bloated in size to such an extent that Firefox ceased to open. At that time, the only remedy offered by the Library systems guy was to delete the bookmark file and start over.

I knew I had to take some action before it became critical. I made a copy of my bookmark file and took a look at the code in a text editor. Immediately, I noticed that there were instances of lines that were much longer than others. A visit to the archives of the mozilla.support.firefox newsgroup revealed a solution.

It turns out that Firefox stores icons for pages that you visit and bookmark as text-encoded binary data.

Look in your bookmark file for 'ICON="data:image/x-icon;base64' and you will probably see many examples of what I'm talking about.

You will note that all bookmarks start with "<DT><A HREF" and end with "</A>" and are one continuous line (I've wrapped it in my example for better display).

Below is an example of a single (polluted) bookmark from bookmarks.html. The line is a total of 2042 characters long, most of which is the "ICON" attribute.

<DT><A HREF="http://www.google.com/" ADD_DATE="1135917265"
LAST_VISIT="1146226277"
ICON="data:image/x-icon;base64,AAABAAEAEBAAAAAAAABoBQAAFgAAAC
gAAAAQAAAAIAAAAAEACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC
AAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA
/wD/AP//AAD///8A//3/AP39/wD6/f8A+P3/AP/8/wD9/P8A+vz/AP/7/wD/+
v8A/vr/APz6/wD4+v8A+/n/APP5/wD/+P8A+vj/AO/4/wDm+P8A2fj/AP/3/w
D/9v8A9vb/AP/1/wD69f8A9PT/AO30/wD/8/8A//L/APnx/wD28P8A///+APj
//gD2//4A9P/+AOP//gD//f4A6f/9AP///AD2//wA8//8APf9/AD///sA/v/7
AOD/+wD/+vsA9/X7APr/+gDv/voA///5AP/9+QD/+/kA+e35AP//+ADm//gA4
f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lEouKRRCg9SXMoW
/U53enGRAFzCRtNO7mTiAyliw30gRTg9VbJCKfYs0j9VmuscfLTFbIy8SOhA0
Inq5Y77GNBMYIxQUJzM2Vxx2wEmfyCYWMRldXCg5MU0aicRUms58SUVeRkwjP
BRSNIfBMkSgvWkyPxVHFIaMSx1/0S9nkq7WdWo1a43Jt2UqgtJERGJ5m6K8y9
2znpNWIYS1UQ89Mmg5cXNaX0EkGyyI3KSsp6mvpaqosaatq7axsQAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAA=" LAST_CHARSET="UTF-8" ID="rdf:#$mEiEn1">Google</A>

By removing the "ICON" attribute and its data, I determined that I could reduce the length of this to 132 characters; a 93.5% (1910 characters) reduction in size. Clearly, this is worth doing.

Before editing the bookmark file, you first need to stop new icons from being added or this problem is just going to recur.

In Firefox's location window, enter "about:config". A long list of file settings will appear.

In the "Filter" search box, type the string "icon".

Locate and toggle the following two entries from "true" to "false" by double-clicking them.

  • browser.chrome.favicons false
  • browser.chrome.site_icons false

Now you need to add the following new entry in "about:config".

  • browser.chrome.load_toolbar_icons 0

You do this by right-clicking in the "about:config" box and selecting "New" > "Integer" as an option.

In the "New integer value" > "Enter the preference name" window, type in "browser.chrome.load_toolbar_icons" and click "OK".

In the "New integer value" > "browser.chrome.load_toolbar_icons" window, type in the integer "0" and click "OK".

When you have done this, no new icons will be added to the bookmark file, but existing icons will not be removed.

To reduce the size of your bookmark file, you have to hand edit and remove all occurences of the "ICON" attribute from the entries the file.

Make a backup copy of bookmarks.html before editing it.

Search for ICON=" and delete the entire attribute (including the "ICON=" part) from there to the next double quote (ICON="...").

In an editor such as NoteTab, that has built-in regular expressions matching functionality, this is pretty easy. Just do a search and replace with the "Regular Exp." box checked and search on this string:

ICON=\".*\"

You want to include a single space before "ICON" and put a backslash before both double quotes to escape them. The .* string, in this case, searches for everything between the double quotes.

The edited line should end up looking similar to this:

<DT><A HREF="http://www.google.com/" ADD_DATE="1135917265" 
LAST_VISIT="1146226277" LAST_CHARSET="UTF-8" 
ID="rdf:#$mEiEn1">Google</A>

The size of my bookmark file was reduced from 477KB to 59.7KB by repeating this process for the entire file.

(Via mozilla.support.firefox)

Posted by Tom on January 24, 2007