Firebug and javascript.options.strict

I’ve had some complaints recently that my site was taking an age to load in Firefox. In fact, anything built with base2 was performing very badly for some Firefox users. My advice to them was to disable Firebug. This solved the problem but I didn’t know why. I use Firebug and wasn’t experiencing any slow down.

Yesterday I received an email from Alex Robinson and now the mystery is solved.

Firefox allows users to set various preferences via the about:config URL. One of these settings, javascript.options.strict , generates various warnings and messages about your JavaScript code. Firebug then takes these messages and turns them into entries in the console. The latest version of base2 was generating about a hundred information/warning messages. Things like, “function does not always return a value”. A Firebug console entry is made up of several DOM elements, so a hundred messages generates several hundred DOM insertions. This is what was causing my site to perform so badly for some users.

I’ve since refactored the base2 code so that it no longer generates any warning or informational messages. I haven’t uploaded this code yet as I have made some other changes which I’ll blog about later.

I recommend that you test your own code with javascript.options.strict set to true.