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.