Firefox 3.1 to dramatically speed up JavaScript

AJAX developers, get your game on.  Firefox version 3.1 will deliver massive speed improvements for JavaScript, the language behind many of the cool interactive effects on today’s web pages.

Andreas Gal and Michael Franz of the University of California, Irvine invented a novel approach to Just-In-Time compilation called “tracing”.  Put simply:  rather than compiling complete, individual methods at runtime, they record trace paths through the code that represent loops, then compile those based on how often they’re called.  That means that the code that gets executed repeatedly is the code that gets compiled — and the compiler doesn’t need to waste time on compiling anything else.

While the theory behind this is pretty advanced, the speed improvement is certainly more than academic.  Mozilla has already built tracing optimization into SpiderMonkey (Firefox’s JavaScript interpreter), re-christening it “TraceMonkey” — with the following results:

As you can see in the graph above, a global loop is almost 40 times faster with TraceMonkey than in Firefox 3.0, and an empty loop is 20 times faster.  With a 22x performance boost on function calls, maybe we’ll see more thorough functional style in JavaScript scripts down the road (yeah, sure).

Don’t use much JavaScript, you say?  Don’t be so sure.  If you use GMail or any number of other online services, you probably run JavaScript.  Most widgets (including ad services) and plugins for WordPress and other blogging platforms use JavaScript.  If you’re curious, do a “View Page Source” in your browser and search for “javascript”.  Much of the implementation of Firefox itself is in JavaScript, as well as its extensions.  So if you’re a Firefox user, this improvement could noticeably speed up your browsing.

And just how many people use Firefox?  According to this graph, almost 19% of web surfers use either Firefox 2.0 or 3.0, up from under 14% last September.  While Internet Explorer 7 still holds a comfortable lead at 47%, we all know that those are the non-geeks who don’t count.  Maybe faster browsing in Firefox will win them over, too.

[Chart Source: Brendan’s Roadmap Updates]


Geeks are Sexy needs YOUR help. Learn more about how YOU can support us here.