a script on this page is causing ie to run slowly

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.


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.


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.


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


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