DSL Ideas and Suggestions :: Moz size-reduction



Official Mozilla Firefox 2.0.0.8: firefox-2.0.0.8.tar.gz
Size: 9464K
Uncompressed: 25180K

i. 'sstrip': sstrip.c
ii. 'advzip' is part of AdvanceCOMP - Source: advancecomp-1.15.tar.gz
iii. 'upx' binary: upx-3.01-i386_linux.tar.bz2

1.
Code Sample
find ./ -name "*.so" | while read i; do sstrip "$i"; done
Size: 25180K -> 25104K
Code Sample
sstrip firefox-bin updater xpicleanup
Size:25104K -> 25004K
2. Delete following files:
Code Sample
browserconfig.properties
chrome/reporter.jar
chrome/reporter.manifest
components/libjsd.so
components/libmozgnome.so
components/libmyspell.so
components/libnkgnomevfs.so
components/libspellchecker.so
components/nsDictionary.js
dictionaries/
extensions/inspector@mozilla.org/
extensions/talkback@mozilla.org/
icons/
mozilla-xremote-client
old-homepage-default.properties
readme.txt
Size: 25004K -> 21308K
3. Some libraries can be made external:
Code Sample
Libs: libfreebl3.so libmozjs.so libnspr4.so libnss3.so libnssckbi.so libplc4.so libplds4.so libsmime3.so libsoftokn3.so libssl3.so libxpcom.so libxpcom_compat.so libxpcom_core.so libxpistub.so
Code Sample
Move into '/usr/lib/':
libmozjs-dev - libmozjs.so
libnspr4-dev - libnspr4.so, libplc4.so, libplds4.so
libnss3-dev - libnss3.so, libsmime3.so, libsoftokn3.so, libssl3.so
libxul0-dev - libxpcom.so, libxpcom_compat.so, libxpcom_core.so
These are left:
Code Sample
libfreebl3.so [228K]
libxpistub.so [8K]
Size: 21308K -> 18420K
4. Strip comments from .js, .css, and .properties files:
Code Sample
find ./ -name "*.js" | \
while read i; \
do cpp -P "$i" > "$i".tmp \
&& mv "$i".tmp "$i"; \
done
find ./ -name "*.css" | \
while read i; \
do cpp -P "$i" > "$i".tmp \
&& mv "$i".tmp "$i"; \
done
* cpp cannot cope with lines that begin with '#'. It will give errors with a few files:
"./defaults/profile/prefs.js:1:3: error: invalid preprocessing directive #Mozilla"
- 'prefs.js' can be deleted.
"./res/EditorOverride.css:121:2: error: invalid preprocessing directive #mozToc
./res/viewsource.css:44:2: error: invalid preprocessing directive #viewsource
./res/viewsource.css:50:2: error: invalid preprocessing directive #viewsource"
- Remove '#', re-run 'cpp -P', reinsert '#'.

find ./ -name "*.properties" | while read i; do \
sed '/^#/d' "$i" > "$i".tmp && mv "$i".tmp "$i" && \
sed '/^$/d' "$i" > "$i".tmp && mv "$i".tmp "$i"; done
Size: 18420K -> 17740K
5. Optimize the .jar archives in 'chrome/':
Code Sample
advzip -z4 *.jar
Size: 17740K -> 14724K
6. Compress 'firefox-bin' with 'upx':
Code Sample
upx --best firefox-bin
Size: 14724K -> 8596K
7. Make tarball:
Code Sample
tar -zcf firefox.tar.gz --numeric-owner firefox/
Size: 8596K -> 6356K

Or, using lzma algorithm of upx:
6. Compress 'firefox-bin' with 'upx --lzma':
Code Sample
upx --lzma --best firefox-bin
Size: 14724K -> 8124K
7. Make tarball:
Code Sample
tar -zcf firefox.tar.gz --numeric-owner firefox/
Size: 8124K -> 5932K

So the idea is: Do the same for all current Mozilla extensions; and centralize these libraries in one extension:
Code Sample
libmozjs.so, libnspr4.so, libplc4.so, libplds4.so, libnss3.so, libsmime3.so, libsoftokn3.so, libssl3.so, libxpcom.so, libxpcom_compat.so, libxpcom_core.so
A tarball is approximately 1.2M; about:buildconfig lists "--enable-optimize=-Os", so this is seemingly the smallest possible.

Combined with a stripped-down gtk2 extension [~1.7M-2.0M], we could get a usable gtk2 Mozilla [Firefox/Thunderbird/etc] in a download size of <10M.

Very impressive - people are bound to ask though, would flash-9 work with this version?
Hopefully yes. The files I deleted seem in no way connected to the working of plug-ins. I am only remotely concerned about these two:
Code Sample
components/libmozgnome.so
components/libnkgnomevfs.so
Flash probably does not need gnome support. Many people compile without gnome support, Flash should be expected to still work in such cases.

Some points:

- you have way too much time :p
- if you compiled FF yourself:
 1) the swiftfox way: drop pango support; some size decrease
 2) with gtk1; more size decrease
 3) with Xlib; most size decrease & most speed increase
 4) when I compiled FF shared, instead of the 11mb half-static official binary, firefox-bin was 74k, loading times dropped, and the total dir size was ~400k smaller than the official..

While the sizes you listed look good, what happened to speed?
How much did loading times grow on a P1? Or is general browsing on low comps slower?
The .jar's were packed without compression to archieve speed.
If all Mozilla extensions were slowed down, how would that affect those without too much processing power?

Next Page...
original here.