Moving Files Into JARs
August 27th, 2009 by tglek
Moving files into jars reduces amount of seeks on startup, and has miscellaneous other performance/organization benefits. I added resource://gre-resources/ which maps to jar:toolkit.jar!/res/.
To move a file into a jar:
- Add a jar.mn entry.
- Remove existing references to the file in Makefile.in, packages-static files
- Add file to the removed-files.in list of dead files
- Update urls refering to the file in the source. Sometimes one has to switch from using file streams and filenames to using channels and URIs. This is the hard part.
- Set your bug as blocking bug 513027.
For an example see bug 508421.
That jar: protocol is one of the many hidden gems of Firefox. You can browse a compressed slice of a website without unpacking it and with an about:config tweak you can view ZIP files in the browser!
The Firefox implementation has got encoding and functionality bugs (#445065, #132008) but it’s still damn cool (#502528).
Unfortunately, extensions usually use the resource: protocol for JavaScript modules – but that feature explicitly requires physical files (https://bugzilla.mozilla.org/show_bug.cgi?id=406538).