Firefox 3.1: Speeding Up the Web With Supercharged JavaScript

The upcoming release of Firefox 3.1 will make many of your favorite, complex web-apps, like Gmail, run considerably faster thanks to some much improved JavaScript tools in the browser. While many still see JavaScript as an awkward way to validate forms or add a little spice to otherwise dull web pages, some sites are using […]

Ff31jsThe upcoming release of Firefox 3.1 will make many of your favorite, complex web-apps, like Gmail, run considerably faster thanks to some much improved JavaScript tools in the browser.

While many still see JavaScript as an awkward way to validate forms or add a little spice to otherwise dull web pages, some sites are using JavaScript to go far beyond its humble beginnings. In fact, many developers see JavaScript as the future of the web.

To help JavaScript along, Mozilla says Firefox 3.1 will give JavaScript a much-needed shot in the arm with its new TraceMonkey JavaScript tool. According to Mike Shaver, Mozilla's VP of Engineering, the new tools in TraceMonkey allow JavaScript code to render on par with native code.

"The goal of the TraceMonkey project – which is still in its early stages," cautions Shaver, "is to take JavaScript performance to another level, where instead of competing against other interpreters, we start to compete against native code."

While part of the gain will be for Ajax-heavy web apps, the new code will also improve Firefox itself since extensions and other Firefox tools are written in JavaScript.

Apple's Safari has already been experimenting with its own new JavaScript engine, SquirrelFish, which uses similar techniques to achieve impressive new rendering speeds. SquirrelFish is scheduled to arrive in Safari 4.

The new JavaScript engines in both browsers use a technique called "trace tree" to improve JavaScript performance. The idea, based on a technique developed by researchers at UC Irvine, uses a tracing mechanism to record the execution path at runtime and then generates compiled code that can be used next time that a particular path is called.

The result is much better performance in the browser. How much better? In some cases Mozilla says the new tools can make JavaScript 20 to 40 times faster. To demonstrate TraceMonkey's potential, Mozilla's Mike Schroepfer put together demo app and found that even now, with many planned optimizations not yet available, the real world performance is about seven times faster than Firefox 3. Check out the video on Schroepfer's blog, which shows a nightly build running alongside Firefox 3 – the improvements are quite dramatic.

As the benchmarks at the top of this post indicate, the speed improvements may be even higher by the time Firefox 3.1 is released at the end of 2008.

For now TraceMonkey is only available via the Firefox nightly builds (Safari's SquirrelFish Engine is also only available via nightly builds), but when the first betas of Firefox 3.1 arrive, they'll bring TraceMonkey – and potentially a much faster web – with them.

See Also: