How to Optimize or Deoptimize Firefox OMNI.JA File
Developing a web browser such as Firefox is not as easy as it seems. It requires a team of brilliant programmers to work together putting up an efficient and fast web browser that is free for us to use. For the Firefox web browser, one of the major improvement on performance is having fewer naked files. Since Firefox version 4, a lot of files, especially the javascripts that used to be in the components folder, are being packed into one file called omni.jar and this effectively reduces 30-100x disk I/O. Omni.jar has been renamed to omni.ja since version 10 to prevent Firefox from being corrupted.
This improvement has caused some problems to some users who prefer to modify the core Javascript files for customization instead of using add-ons or extensions. If they’re using an older version of 7-Zip such as 9.20 to open the omni.ja file, 7-Zip will report an error saying “Can not open file omni.ja as archive” although it has been reported that the omni.ja file is actually a ZIP file.
A simple workaround is to rename the omni.ja file extension to .zip and Windows will be able to open and extract the files. They can then modify the files according to their needs, repack them into a ZIP file, and finally rename back the file extension to .ja. Although this method works, it is not recommended due to additional optimization being done on the original omni.ja file which can yield an additional 2-3x reduction in disk I/O.
The optimized omni.ja file is not a standard ZIP format because the layout has been changed. Usually the index is placed at the end of the file, but an optimized omni.ja places the index at the front of the file to minimize disk seeks and to maximize read ahead benefits. This is the reason why some picky archiver programs such as the older version of 7-Zip 9.20 are unable to open omni.ja even though it is a ZIP file. Running a “test archive” function in 7-Zip will show that it detected error in headers.Fortunately the author of 7-Zip has added the support to open the optimized omni.ja file in the latest version. While you have no problems opening omni.ja with the latest 7-Zip, it is not possible to automatically update the edited files. As you can see from the screenshot below, we tried editing a file from the omni.ja and 7-Zip throws an error saying that it is read-only when it tries to update the edited file in the archive.
Now we’ll show you how to deoptimize the optimized omni.ja file so that you can conveniently edit any files directly from 7-Zip and then reoptimize it so you don’t lose the additional 2-3x reduction in disk I/O.
1. Download ActivePython and install. If you’re running a 64-bit version of Windows, make sure to download the x64 version of ActivePython.
2. Download the updated optimizejars.py python script that has been fixed to work with omni.ja
3. For simplicity, place both omni.jar file and optimizejars.py file on your desktop. Run Command Prompt by pressing the Start button, type cmd and press Enter key. Change the directory to your desktop by typing “cd desktop”, hit Enter and type the command below to deoptimize the omni.ja file.
optimizejars.py --deoptimize ./ ./ ./
Alternatively, you can also copy the optimizejars.py file into the directory where omni.ja resides which is usually at C:\Program Files\Mozilla Firefox\, then run the command prompt as administrator, change the directory to the path where omni.ja is located and run the deoptimize command shown above. If you get an permission denied IOError 13 after running the deoptimize command, that means the command prompt is not run as administrator.
After a successful deoptimization, the omni.ja file becomes a standard ZIP file which can be opened by any archiver program. After making changes to the files inside omni.ja, you should re-optimize the file again for additional performance benefit by typing a slightly different command shown below.
optimizejars.py --optimize ./ ./ ./
Below is the proof of the optimization and deoptimization for the omni.ja file. The image below shows the original optimized omni.ja file opened with Notepad, a standard text editor built-in to Windows operating system. The beginning of the file header shows PK which is a standard signature for a ZIP file. You will find a lot of file paths which are the indexes of files in the archive at the beginning of omni.ja file as well.
Now let us take a look at the deoptimized omni.ja file in Notepad. We’ve scrolled right to the end of the file and as you can see, the indexes of files are being placed here instead and not at the beginning. If you look at the beginning of the file, you should also see that it starts with PK.
Do take note that whenever Firefox is updated, it is very likely that the omni.ja file will get updated as well overwriting your modified omni.ja file. This is one of the main reasons why extensions should be used instead of modifying the Firefox core files as it retains the modification while allowing you to easily keep your version of Firefox up to date.
The current version of optimizejars.py here
github.com/zotero/zotero-standalone-build/blob/e3396b16607455c95e7009342971309e340cbb89/scripts/optimizejars.py
My omni.ja is huge (c. 50 MB), and I have 2 of them, both the same date but different sizes. Can it be slimmed own and/or one deleted?
how do i do this for firefox 52?
thanks pal.
i’m using ff4
dont use winrar! it crashes your ff although u can archive it back.
works perfectly with 7zip for extracting and archieving.
Hey Raymond,
Nice Hack….worked well,
I’m using Total Commander to open omni.jar, hit Ctrl + Pg Down to open omni.jar and you can edit omni.jar without Python. xD
ghisler.com/download.htm
Hey Thanks for the tweak. It worked for me. Downloaded python and re-optimized the file as well.
Thanks for the techie share Ray ;).
@raymond
thanks……..
good tip
thanks