views:

9841

answers:

10

The problem is in the title - IE is misbehaving and is saying that there is a script running slowly - FF and Chrome don't have this problem.

How can I find the problem . .there's a lot of JS on that page. Checking by hand is not a good ideea

EDIT : It's a page from a project i'm working on... but I need a tool to find the problem.

End : It turned out to be the UpdatePanel - somehow it would get "confused" and would take too long to process something. I just threw it out the window - will only use JQuery from now on :D.

And I'm selecting Remy Sharp's answere because I really didn't know about the tool and it seems pretty cool.

+2  A: 

Remove half the code and see if it still happens. If not, it's in the half you removed. Repeat until you figure out what code block is causing the problem.

Rahul
already tried this one - but still no luck ... will keep trying. I was hoping for a tool of some sort.
sirrocco
+2  A: 

It is usually an infinite loop that causes this. Check your loops and their exit conditions.

Rohit
A: 

I don't believe there's a tool that can find the offending script. You might try attaching an IE debugger like Visual Studio and maybe it will break at the point where the problem is occurring. But I can't give any guarantees on that working.

In the past when I've had similar problems I've simply commented out sections of code to test narrow down where the issue is occurring, usually in a binary search type pattern. Comment out half of the javascript libraries, etc...

Aside from that as others have said, this type of problem occurs from large loops and many setTimeout function calls or setTimeout recursive loops.

Esteban Brenes
+2  A: 

one of the things on my todo list is to figure out how to download IE 8 beta without blowing away 6 or 7, and learn what the jscript profiler can do. You can be a pioneer!

http://blogs.msdn.com/ie/archive/2008/09/11/introducing-the-ie8-developer-tools-jscript-profiler.aspx

Gene T
matt b
A: 

If javascript ties up page processing for more than 10 seconds, you get this message. IE obviously has a slower javascript engine, causing this.

I'm guessing that some code optimization will certainly help, and try reducing the amount of javascript executing on page load. Perhaps use setTimeout() to defer processing of some unnecessary things if you have to.

As far as tools go, use Firebug's profiler to see where you're spending so much time.

Eric Wendelin
The thing is that it's not waiting for 10 seconds .. maybe 2-3 seconds before showing the message. But ... until monday I'll have no way to test ... will update on monday.
sirrocco
If that's the case, it's likely you're in an infinite loop. To prove this, you might try Firefox on a really, really slow machine or IE on a really really fast one.
Eric Wendelin
Do you have any reference for the 10 second limit? I have never seen that before but it does coincide with my own experiences.
liammclennan
+4  A: 

Get yourself a copy of the IBM Page Profiler:

http://alphaworks.ibm.com/tech/pagedetailer

It's free (always a win). Start it up in the background, give it a few seconds, then refresh the page in IE. Go back to the profiler and it will list out all the resources used on the page and give you detailed profile information - in particular where JavaScript is taking a long time to execute.

It should be a good start to finding the source of your problem.

If the script tags are inline, I'd suggest creating a local copy of the file and separating out the script tags to separate files if you can.

Remy Sharp
I might be missing something, but the tool you linked doesn't appear to do the javascript profiling you suggested. All it does is give details on what resources were loaded.
andynormancx
The tool is for analysing the entire page. So it breaks down the individual components, tells me the request time, the delivery time and the render (or process time) - both on empty and primed cache. This would help identify slow components, and help benchmark any changes you make.
Remy Sharp
but how can that give the solution to this problem as this problem is due to some ong running javascript or infinite loop in the code block page profiler only gicves network part of it
serioys sam
Very nice tool, thanks for telling about
Amr ElGarhy
A: 

For IE, the dialog is based on the # of JS commands processed. See here for info & method to change default: http://support.microsoft.com/kb/175500

+6  A: 

Long running scripts are detected differently by different browsers:

  • IE will raise the warning once 5 Millions statements have been executed
  • Firefox will warn if the script takes longer than 10 seconds
  • Safari will warn if the script takes longer than 5 seconds
  • Chrome (1.0) has no set limit and will simply keep trying until an OutOfMemory exception at which point it crashes
  • Opera will just continue to run forever, without warning.

As such - the best way to avoid these problems is by reducing looping, recursion and DOM manipulation.

nikmd23
+1  A: 

Hi All,

I just blogged about this and put what I think is a pretty stylish solution. So have a look. As mentioned above my solution just breaks up long running operations into chunks but I provide a nice utility class to do this.

Thanks

Guido

gatapia