Recent Changes -



We'll tour Mozilla's source code and some of the ways to hack it, with an eye toward practical hackery. How the heck do you build this beast? What's that XPCOM and NSPR stuff? Which modules do what in the code ... and which ones are amenable to a quick grep-and-tweak, versus the ones that should have big signs plastered over them warning "Here there be dragons"? (Leaving aside for the moment the ever-important debate over whether Mozilla is a dinosaur or a dragon.)

Some programming knowledge is assumed, but we won't be spending a lot of time on the innards of the C++ core libraries -- a surprising amount of Firefox's code is fairly high level Javascript and XUL, and you can browse a lot of it without even downloading a source tree.

I'll discuss the difference between XUL and XBL, how the JAR files are organized (and easy ways to look at them), and where Javascript fits in. When should you create an extension instead of just hacking the source tree -- and what options are there in between? How do you get started writing an extension? What's this xulrunner thing and how do you use it to make standalone apps?

By the end of this tutorial you'll have a better idea as to what parts of Mozilla are easily hackable, and you'll know how to write a simple Firefox extension as well as how to tweak your local Firefox installation.


No preparation is required, but if you want to follow along on a laptop, I'd recommend you install some software beforehand. What you need depends on what aspects of Firefox/Mozilla you're most interested in hacking.

To hack your installed Firefox:

All you need is firefox installed. Any version, distro versions okay; I'll be using the most recent 3.0.x from If you prefer seamonkey, you'll probably be able to adapt all the techniques though exact filenames may be different.

You'll also want an unzip program, and/or an editor that can read jar files, e.g. emacs (which edits jars automatically) or vim (see editing jars with vim).

See the bottom of the page for a script for unjarring your chrome.

To write an extension:

Same requirements as the previous section.

To hack or explore the latest C++ source:

Install Mercurial
and choose a merge tool:

Pull (and build, if you like) the latest source:
(Warning: PmWiki doesn't highlight that whole URL. To go to the real URL, triple-click over "Mercurial" to select the whole line, then Ctrl-middleclick to open the URL in a new tab.)
Command to pull the latest repository:
hg clone src
(656 Mb pure source, 1.9G after building Firefox.)

Unjarring chrome

 #!/usr/bin/perl -w
 # Any copyright is dedicated to the Public Domain.

 foreach (glob("*.jar"))
   print $_ . "\n";

   # Unzip it into a directory named after the jar file.
   system("unzip -q $_ -d $1");

 foreach (glob("*.manifest"))
   local $^I = ".orig";
   local @ARGV = ($_);
   while (<>)

 system("rm *.orig");
Page last modified on January 21, 2009, at 03:02 PM