After more than 18 months of hard graft, Mozilla has finally succeeded in landing a big addition to Firefox’s JavaScript engine that, upon initial testing, speeds up the web — or at least the vast swaths of it that use JavaScript — by around 20 to 30%. The new feature is the introduction of type inference to Firefox’s JaegerMonkey JIT compiler, and it will debut with Firefox 9. It was originally meant to land a few months ago, in time for Firefox 5, but it took until now to reach a stage where it’s almost ready for primetime.

If you’re a web programmer, your mind will have been summarily blown. If you’re less technically minded, however, here’s a basic description of type inference and why it will speed up Firefox’s JavaScript performance by such a large margin. In every programming language, variables and functions have types. A type can be an integer, a string, a float (decimal number), an array, a class — and so on. These are internal constructs that are incredibly important to a programming language compiler or interpreter.

Some languages are strongly typed, which means that the programmer must define the type of every class, function, and variable that he uses; tiresome, but it can have big pay-offs in terms of overall speed. Other languages, like JavaScript, are weakly typed, which means that the programmer doesn’t have to worry about such piffling minutiae; you can just write some code and let the compiler do the heavy lifting. Type inference fills in the gap between strong and weak typing so that you can still write sloppy code, but reap some of the speed boost.

In the case of Firefox 9, the type inference engine seems to produce up to 30% faster JavaScript execution. It varies from benchmark to benchmark, but the performance improvement is unmistakable. The ExtremeTech benchmark rig is an Intel i7 930 @ 3.8GHz with 6GB of RAM and an Nvidia GTX 460, and these are the figures we obtained: With Firefox 9, and without type inference, the Kraken benchmark takes 3895 milliseconds; with type inference enabled it takes just 2763 milliseconds. Firefox 9, without type inference, scores 6075 on the V8 JavaScript Benchmark; with type inference, the score jumps up to 6585. Even on banal tests like Microsoft’s HTML5 Sudoku, type inference improves the solving time for 10,000 grids from 2.6 down to 1.62 seconds — and yes, the FishBowl framerate, at 2,000 fish, is increased by 15-20% with type inference enabled.

In case you were wondering, the JavaScript engine in Firefox 6 (the current stable build that you are probably using) is basically the same as Firefox 9 — but without type inference. In other words, Firefox 9 will be around 30% faster than your current browser.

Finally, before you run out and install the latest Firefox 9 nightly, bear in mind that type inference in its pre-release form can also cause some scripts to slow down — and if you’re using a 64-bit build because it’s meant to be faster, bad news: the 32-bit build with type inference certainly seems to be faster at the moment. By the time Firefox 9 reaches the Aurora channel at the end of September, though, type inference should just make your web surfing 20-30% faster — period.

Download the latest Firefox 9 nightly with type inference, or read more about type inference itself