The site uses cookies that you may not want. Continued use means acceptance. For more information see our privacy policy.

Slow JavaScript in My Browser?

I look at a case of finding bad performance in ECMAScript/Javascript benchmarks, leading to a hunt for what’s wrong with my browser.

Another short one for November. Firefox 9 beta is now out, and that means the awesome package manager for Iceweasel has already got it packaged for Debian Unstable. In reading up on what’s new in Firefox 9, people mentioned Type Inference being added to its JavaScript engine, bringing some nice performance gains.

That led me to want to see how fast my browser is these days. For that I hopped on to the Kraken benchmark and V8 benchmark (separately, of course, to prevent one from slowing the other). Then I became concerned.

My everyday browser and profile:

  • Kraken: 12008ms
  • V8: 1522

When I tried Kraken from Firefox Safe Mode, it actually got so bad that the imaging: gaussian-blur portion of the test was timing out. For the sake of consistency/thoroughness, I’ve repeated the benchmarks from Safe Mode:

  • Kraken: 59363ms
  • V8: 583

(Note that on the Kraken tests where it caused the ‘slow script’ dialog to pop up, I had to manually tell it not to issue the warning the first time, which means a score even worse than it would have been (humans are slow).)

[Edit: Mozilla Bugzilla: Bug 453642 shows that Just In Time (JIT) compilation of JavaScript is disabled in Firefox Safe Mode, which clears that up.]

As my local builds of Firefox are on version 11 (the current nightly), using one of them won’t give me the exact same code to test against, but it’s a start. I can also download a copy of the Firefox 9 beta as compiled by Mozilla, and run that, to give me another datapoint.

Why am I doing this? Because at this point, it’s not obviously a bug. It could be caused by some other problem with my system, and even if it is a bug in Iceweasel, the extra data can prove useful.


  • Iceweasel with my original profile:

    • Kraken: 12008ms
    • V8: 1522
  • My local build:

    • Kraken: 3612ms
    • V8: 5476
  • Official Firefox 9 beta:

    • Kraken: 3439ms
    • V8: 6324

So we know that there’s a problem. Now the question is whether it’s with the package itself or something else on my system.

Here I try Iceweasel with a fresh profile:

  • Kraken: 3711ms
  • V8: 5696

Okay. So now I know, no doubt, that it’s my profile. What’s disturbing is that the problem still showed itself in safe mode.

My first step in tracking down my profile’s problem will be to disable all add-ons:

  • Kraken: 3693ms
  • V8: 5691

Ouch. Still not sure why safe-mode would have degenerate behavior, but at least I can now do a binary search (disabling half the add-ons, and test, etc. until I narrow it to a single add-on) to find which add-on is causing my problem.

And the winner is… Firebug. Firebug is an excellent extensions that lets the user inspect the web they use every day, but to do that it has to have its hands in the pie of the web, which can slow things down. Let’s see what we can tweak about my current settings for Firebug to hopefully leave it enabled while getting acceptable performance.

And a search turns up Mozillazine Forums: TM and PM Performance Thread: Comment by phuzi0n:

Is Firebug killing javascript performance after TI landed for anyone else? I tried updating to the latest stable Firebug 1.8.2 and then to 1.9.0a1 but it still slows down v8 benchmark by ~4x and sunspider by ~2x. I made sure that Firebug’s javascript profiling is disabled (with Firebug profiling enabled v8 is ~10x slower).

So, the current vintage of Firebug has some issues with the changes to JavaScript. That’s unfortunate, but knowing is half the battle.

In retrospect, I should have tested with a fresh profile before worrying about other builds of Firefox, as it would have highlighted the source of the problem much faster, but I was thrown off by the really bad performance in safe-mode, which led me to believe it couldn’t be an add-on.

For the time being, I am going to keep Firebug on, but if I run into pages that seem slow, I can always turn it off.

The World-wide Web

To the point: we’re all mostly just using the web, and we’re all using it in more diverse ways than ever. So, what is the important thing? There are several.

The World-wide Web, or the WW as it is known.  If but for a hyphen all those years ago, how many less characters would be have to type to navigate this landscape?!

Alas, we still type www; or some of us do and some use various shortcuts.  Some of us are on mobile devices that predict we’re about to text someone about a website and promptly display out-of-area…

To the point: we’re all mostly just using the web, and we’re all using it in more diverse ways than ever.  So, what is the important thing?  There are several.


A couple weeks ago the NYT Magazine was devoted to screens.  More than ever our monitors and TVs have grown while our cell phones and laptops have first shrank and then grown and shrank and grown.

The important thing here is that there’s less telling than ever what size screen a web page will be viewed on.  The future is more of the same in that regard, but as small devices get larger screens and as resolutions improve this becomes less important.


The advent of AJAX and the long-entrenchment of Adobe Flash have made the web crunchier.  Parts are still the old web, and the standards there have rapidly improved.  The AJAXian incursion broke that: some sites have it, some don’t.  Some sites implement it well, some don’t.  Above all, it presents a stumbling block for standardized interaction.

Example: in gMail I can click a checkbox, hold shift, and click another checkbox with the result being the intervening boxes become checked.  So, then, in site can I expect this?  I can expect all I want, but the actual behavior may not be consistent with my expectations.

The Browser Congress

In many ways the overarching state of web browsers has improved (for those who install or upgrade their browsers).  There is less of a browser war and more of a congress these days.  The main (and longstanding champion) crumudgeon is Microsoft with Internet Explorer.  Don’t expect that to change, except in that their marketshare is slowly but surely declining.

The important thing here is that the overall state of the web is in flux: it’s improving on many levels, but there are new concerns.  Rendering engines are rapidly approaching perfection (curmudgeons aside), so I won’t discuss them.

The Javascript Push

The new push inside the browser is for more, better, faster Javascript engines.  The goal is to provide outstanding performance for AJAX and other Javascript uses.  The general path is to provide JIT compilation to native code for execution.  You may see stories with titles like “Firefox kicks Chrome in the knee, but Webkit takes a cheese grater to both of their knuckles.”

The important thing to take away from these is not that any browser is particularly better, but that they are all better.  One may be a little faster, but they are all moving toward an acceptable performance plateau.

The Plugin Push

The other big push has one foot in and one foot out of the browser: Flash, Silverlight, Java.  Well, Java hasn’t been pushed as Silverlight and Flash have been.  Flash is the current top dog, though the Java plugin is probably nearly as widespread.

The problem is that if SVG support were up to snuff these plugins wouldn’t really need to exist to the extent they do.  With the aforementioned JS engines faster than ever they should be fine for most purposes.  With Silverlight and Java there is access to some outside code paths.

Java is the winner of the three in my book: as far as I am aware it is the closest of the three to a conduit to allow execution of code without adding a bunch of specific content/functionality.

Silverlight is intermediate between Flash and Java plugin.  It still provides some of the unnecessary things that Flash does, but it also provides access to .NET language use from what I know of it.

Flash has entrenchment going for it.  It has added better non-Windows support, which is good too.  But above all, the use of a plugin should either be to provide a full application or to provide a bare connector to be built on top of.

The Soft War

The soft war is roughly the idea that ‘Internet’ is becoming (? is?) synonymous with the web.  The internet supports so much more, and while we still use some aspects, we use them less than we used to and with less awareness than we used to have.

This is good for Google, as they are a web company: they are foremost interested in indexing and advertising in your browser.  But in many ways it’s bad for the users: it places a big bet on browser security and on anti-phishing technology.

The important thing to understand about the web, for it to remain a dominant technology, is that it must:

  • continue to give the user the power
  • be augmented with user-friendly encryption technology
  • gain data portability sanity

Anyway, that’s what I’m thinking about today.

Google Chrome: N Browsing Technology

Just a short note about the forthcoming Google Chrome browser (to be launched tomorrow). Looking at the Google Notebook leak, no Linux-y Goodness ™ just yet. 🙁

Looks like tomorrow Google will release their own open source browser called “Google Chrome.”

It features:

  1. Prominent tabbing (the top of the browser is composed of tabs)
  2. Threading (each tab is its own process)
  3. Integrated Googleness (Gears, integrated Google searching, etc.)
  4. V8 Javascript VM (faster? remains to be seen)
  5. Webkit rendering (a la Safari, Konqueror)

I called it “N Browsing Technology” because of the threading aspect.  It will be interesting to see how they handle that.  The comic they put out admits to higher memory use initially, but it’s not yet clear how small each thread will be and how much sharing is possible between the instances (that’s partly OS dependent anyway).

It will be interesting to see whether this is a Windows-only release or Windows+Mac or if they’ll actually hit us with a Zero-Day Linux Release ™.

Not holding my breath on that one, but that would be a pleasant surprise.

It will also be interesting to see if they have taken a note from Mozilla and made this extension-friendly or not.

Anyway, it’s exciting even if it doesn’t replace Firefox as my browser of choice.  Certainly will try it out tomorrow (if there’s a linux version, of course).

Bah.  Some more news seems to suggest the initial release will be Windows-only.  I am not installing Windows, not even to try Google’s browser out.

Update: The other notable about this release is the fact that they are using what appears to me to be some kind of temporary 404 that isn’t part of their regular system.  My guess on this is that whatever their webservers are (probably some distant cousin of Apache at this point?) they have a redirect level that allows them to redirect to a static file and someone threw it together just to have the ease of waiting until X:xx o’clock and “flipping the switch” (probably just swapping out a conf somewhere).

Also, I find the choice of name interesting as Mozilla heavily uses the term chrome to refer to its UI.