Google Analytics JavaScript Error (cannot access optimized closure in ga.js
Well, for those of you who are developers out there, you may have noticed that if you’re using FireBug 1.4.5 , you may be getting a JavaScript error caused by in ga.js. ga.js is the JavaScript file that Google Analytics uses to allow developers to track traffic/usage statistics for their website, but recently FireBug in FireFox has been producing an error for developers everywhere.
Continue reading for screen-shots and some more details!
The bad news: You have to look at it, and you know that it’s going to tear you apart because you love to write code that’s error free, and you can’t stand seeing a JavaScript error on a website you’ve built, even if it’s not your fault!
The good news: It’s harmless. I’ve read elsewhere that some users have had problems with this error effecting other JavaScript code, but I haven’t seen this on any of my sites. Analytics still works properly and is still tracking your site.
The solution: Wait it out, let’s hope that FireBug can fix the underlying issue and hopefully we’ll get FireBug /Google Analytics working smoothly together sooner than later.
UPDATE:
A visitor sent in this URL from Mozilla.org, which describes a similar issue…
-and-
we checked the change log for Google Analytics and it appears that changes are being made to the setCookiePersistence function that may be part of the problem?
What are your thoughts?

This is strictly an issue with Firebug not being able to introspect some compiled Javascript. It’s not a bug in ga.js. It occurs occasionally in other libraries like jQuery and Dojo as well.
Comment by Blah — December 6, 2009 @ 11:35 pm
Hi, I’m on OS X, Firefox 3.5.8, Firebug 1.5.3. I just started getting this “cannot access optimized closure” error today with a website I’m developing. However, I’m not using Google Analytics (GA) at all!! So I do not believe your hypothesis is correct. As far as I can tell, this “optimized closure” problem isn’t linked to the GA js file as you suggested. In my case, it was triggered by DeepLiquid’s JQuery-based JCrop javascript image cropping code. Therefore, I don’t think it’s linked to any particular JS code. What is more frustrating is that this webpage I’m developing worked last week. Only today, when I ran a unit test on the page, did this error pop up for the first time in the firebug console. Nothing in the code has changed, but I did update Firefox and Firebug a few days ago which I believe ‘infected’ me with a version that suffers from this bug. Upon further reading in the links you provided in your update, I believe this is a Firefox or Firebug bug exclusively. THERE IS A FIX: disable firebug. The JS on the page will run fine. Hopefully there’s a fix soon! -Josh
Comment by josh v — March 20, 2010 @ 11:56 pm