Moz size-reduction
Forum: DSL Ideas and Suggestions
Topic: Moz size-reduction
started by: stupid_idiot
Posted by stupid_idiot on Oct. 23 2007,18:24
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 -> 25104KCode 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/[email protected]/ extensions/[email protected]/ 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
Posted by stupid_idiot on Oct. 23 2007,18:56
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.
Posted by Juanito on Oct. 24 2007,03:39
Very impressive - people are bound to ask though, would flash-9 work with this version?
Posted by stupid_idiot on Oct. 24 2007,12:09
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.
Posted by curaga on Oct. 24 2007,14:53
Some points:
- you have way too much time - 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?
Posted by ^thehatsrule^ on Oct. 24 2007,15:58
Afaik from previous posts, flash9 depends on gtk2.
Posted by curaga on Oct. 24 2007,16:38
The fact Flash itself depends on gtk2 should not mean FF needs to have it too, does it?
Posted by ^thehatsrule^ on Oct. 24 2007,19:36
Well, iirc gtk2 and "gtk2 capable browser". Not sure what that means.
Posted by stupid_idiot on Oct. 25 2007,02:45
Quote (curaga @ Oct. 24 2007,18:53) | 1) the swiftfox way: drop pango support; some size decrease | This is worth a try!Quote | 2) with gtk1; more size decrease | Looking at 'ldd libflashplayer.so', Flash 9 seems to need gtk2.Quote | 3) with Xlib; most size decrease & most speed increase | I once tried '--enable-default-toolkit=xlib', it would inadvertantly quit after a few user actions (e.g. 'open webpage', 'click on link', 'Huh?'). At that time, I did recompile to make sure it was not a fluke. Perhaps I put something wrong in '.mozconfig'? Flash 7 could work - 'libflashplayer.so' [v7] only needs xlibs, not gtk1.2.Quote | 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.. | Yes, 'firefox-bin' decreases, but the 'components/' directory increases exponentially since functions are put in 'components/' as '.xpt' files. If we have a single large 'firefox-bin', we probably would get higher compression with upx, versus many smaller files compressed with gzip.Quote | 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? | Yes, I agree this needs to be tested on low-end machines (P1/P2, yes?). Unfortunately, I don't have an old PC any longer; maybe someone else can test.
Posted by stupid_idiot on Oct. 25 2007,03:02
Comparison: - Comments were stripped from .js files in 'components/'. - Did 'sstrip' on .so files in 'components/'. - For FF-2.0, I removed these files from 'components/':Code Sample | libmozgnome.so libmyspell.so libnkgnomevfs.so libspellchecker.so |
Official FF 2.0.0.7:Code Sample | 1. sstrip firefox-bin 2. upx --best firefox-bin 3. du -cs components/ firefox-bin 1648 components/ 4104 firefox-bin 5752 total 4. tar -zcf test.tar.gz components/ firefox-bin 5. du test.tar.gz 4548 test.tar.gz | FF-1.0.6 from DSL:Code Sample | 1. sstrip firefox-bin 2. du -cs components/ firefox-bin 11628 components/ 68 firefox-bin 11696 total 3. tar -zcf test.tar.gz components/ firefox-bin 4. du test.tar.gz 4768 test.tar.gz |
|