jQuery spikes CPU in Firefox
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 whe开发者_运维问答n 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?
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
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.
精彩评论