Finding slow JS

I’ve been working on a page on our site which completes loading, but hangs on a Javascript (so Document Complete never gets fired).

Although this is not a huge problem, it means the page is never finished loading (some users may wait for it?). It also reports huge loading times in Google’s Webmaster Tools Performance graphs (average of 30 seconds). I also ran chartbeat and found that it wasn’t unusual to see this page take 120s to load.

Is there a way to debug which JS function is holding up my page?

Hopefully you saw the firebug response on the exceptional performance list. If it is only happening on IE then you can also look at DynaTrace Ajax Edition which is a nice free profiler for IE.

If all else fails, you can start blocking js files from the tests to help narrow it down (and once you have it down to a file start commenting out code until it goes away).

-Pat