30

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.

sirrocco
  • 7,975
  • 4
  • 59
  • 81
  • 1
    http://support.microsoft.com/kb/175500 –  Nov 03 '10 at 04:34
  • Thanks, that was the answer I was looking for. I've created a page that will be run on a local machine for a customer and it is very JS intensive (allow searching/sorting of 100,000s of records), so there really wasn't a way to "optimize" any further, it was just a matter of a lot of data being operated on. – jsuggs Jan 27 '11 at 20:24

14 Answers14

52

Long running scripts are detected differently by different browsers:

  • IE will raise the warning once 5 million statements have been executed (more info on MSDN)
  • Firefox will warn if the script takes longer than 10 seconds (more info on MDN)
  • 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.

Nicholas Zakas has written an excellent article covering this topic.

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

nikmd23
  • 9,095
  • 4
  • 42
  • 57
18

Get yourself a copy of the IBM Page Profiler:

https://www.ibm.com/developerworks/community/groups/service/html/communityview?communityUuid=61d74777-1701-4014-bfc0-96067ed50156

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
  • 4,520
  • 3
  • 23
  • 40
  • 2
    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 Feb 19 '09 at 10:27
  • 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 Feb 26 '09 at 15:47
  • 1
    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 Apr 21 '09 at 03:27
  • Looks like the link above is no longer valid and I can't find a valid link via Google. Anyone know if the pagedetailer app is still available anywhere? – Cory House Oct 03 '11 at 13:11
  • @CoryHouse did some googling and searching inside ibm's site and found that bad boy again. – Remy Sharp Oct 23 '11 at 08:57
  • but this is same as network tab in IE9 and above or Chrome browser in Developers Tool, How more advantageous is this then inbuilt available.. – Punith Raj Aug 22 '12 at 13:20
  • the ie8 dev tools are a creepy mess, so this is way better... and compatibility mode to check out ie8 in a higher ie version is another creepy mess. you really should only do compatibility testing if you really know enough about the context of the lower ie emulation. – Guntram Sep 19 '14 at 14:57
9

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
  • 12,181
  • 5
  • 43
  • 64
  • 2
    already tried this one - but still no luck ... will keep trying. I was hoping for a tool of some sort. – sirrocco Oct 17 '08 at 15:49
  • Worked for me. the culprit was selectivizr. here's the fix:- https://github.com/keithclark/selectivizr/pull/51/files – BenG Sep 04 '15 at 11:11
3

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

Rohit
  • 1,710
  • 5
  • 20
  • 29
1

I found that adding alert('before X') alert('after X') was helpful for me to find my issue. I added them to my $(function () {

}

Travis
  • 2,105
  • 2
  • 26
  • 35
1

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

1

you can also check if there is a google analytics javascript include in your page. The bug occured only with IE and once the google code was removed, it worked!

d13
  • 11
  • 1
1

Make sure that below JavaScript code is run only once:

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(win_onload);

Above code is inside the function win_onload().

animuson
  • 53,861
  • 28
  • 137
  • 147
dude_id
  • 11
  • 1
0

In my case having too many ASP.NET HoverMenuExtender controls in a GridView bound to a lot of rows was causing extremely slow performance. I removed the HoverMenuExtender and my speed issues (and the dialog) went away. Not quite related to why the dialog pops up, but it might help someone.

Marcel
  • 7,909
  • 5
  • 22
  • 25
0

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
  • 1,153
  • 1
  • 15
  • 20
0

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
  • 43,147
  • 9
  • 68
  • 92
  • 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 Oct 17 '08 at 18:47
  • 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 Oct 17 '08 at 19:00
  • 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 Nov 18 '08 at 06:34
0

@nikmd23 answer is informative..

My 2 cents here... I had the script warning issue - due to loading a dropdown list items with the help of for loop.

I referred @Eric Leschinski post in Disabling the long-running-script message in Internet Explorer.

Refer setTimeout for loading items in a dropdown list to see how I resolved this problem

Community
  • 1
  • 1
LCJ
  • 22,196
  • 67
  • 260
  • 418
0

There are few reason for this kind of alert

  1. No. of JS instructions executed by IE exceeds predefined limits. This can be fixed by editing windows registry see Here

  2. Optimize the javascript code so that execution time is reduced.

  3. JS code optimization is a real trial and error subject and there are few thumb rules to do so. Just Google it.
Kinu
  • 1
  • 2
  • It is really difficult to find out which script is bottle neck. May be visual studio debugger can be used to trace the spot. – Kinu Sep 16 '14 at 13:37
0

If you have control over the JavaScript, you could break it into separate scripts or try a Lazy Load approach.

Just my $.02

Chris G.
  • 329
  • 4
  • 17