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.

can not open file omni.ja as archive

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.

omnija headers error

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.

can not update file read-only

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 ./ ./ ./

deoptimize omni.ja

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.

omnija optimized notepad

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.

omnija deoptimized notepad

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.

10 Comments - Write a Comment

  1. Fedd 3 years ago
  2. Terry Tortoise 5 years ago
  3. dan komis 7 years ago
  4. den 12 years ago
  5. Jobin 14 years ago
  6. Cattleya 14 years ago
  7. Jisan 14 years ago
  8. INDRANIL 14 years ago
  9. Narender Lamba 14 years ago
  10. asfour 14 years ago

Leave a Reply

Your email address will not be published. Required fields are marked *

Note: Your comment is subject to approval. Read our Terms of Use. If you are seeking additional information on this article, please contact us directly.