views:

183

answers:

2

I got quite a few jQuery scripts in my js file, and now I'm experiencing the CPU going through the roof when I open the page in Firefox.

Looking at Firebugs console panel, I see the following error: too much recursion.

Then it refers to my jquery-1.3.2.min.js file.

How can I discover which jQuery function triggers the CPU spike?

I know I can deactivate one and one jQuery function, till I find the cause. I'm just hoping there is a better way of debugging.

UPDATE

I discovered when I opened the script from Firebug, that the jquery-1.3.2.min.js file belonged to another site (one of the many pges I have open in my Browser).

I was fooled because the browser spiked only when I opened my own page. Could it be that this occurs then the browser loads both jquery-1.3.2.min.js and jquery-1.3.2.js?

+1  A: 

Does this happen in IE8 as well? IE8 has a profiler that will tell you how much time is being spent on each javascript function and how many times they get called. (Hit f12 and click profiler then hit start profiling and load your page)

Edit: It sounds like you might be passing something unexpected to jQuery which is causing jQuery to recur infinitely.

You might try this logging plugin to see what happens before the crash

Mike Blandford
I've only noticed this in FF - as I'm using this when developing websites.
Steven
+1  A: 

Too much recursion means that some function, say f(), is calling itself and then itself again too many times. Or maybe f() calls g() and g() calls f() etc... Each function call results in growth of the stack.

natrium42
The question is "How can I discover which jQuery function triggers the CPU spike?" and not "What is recursion?"
strager
Just need to understand your own code.
natrium42
And maybe even post the code.
meder
Sure, I can post the code. It's only 1500 lines of javascript code....
Steven