Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoiding "Stop Script?" Dialog in IE

I have some computation-heavy Javascript code that I want to run as part of my application. I understand that I'm sharing resources with the UI thread so I've made the UI very responsive by breaking it into chunks and using Angular's $timeout to execute each small chunk at a time. This works fine, except in Internet Explorer 8, where I consistently get the prompt "Stop running this script?"

How do I understand IE8's threshold for "too much script" so that I can work around it? I'm returning control to the main thread often enough for the application to be responsive and problem-free in other browsers. I don't have any infinite loop situations or anything.

like image 328
blaster Avatar asked Mar 03 '26 22:03

blaster


1 Answers

IE8's concept of a "slow script" is based on the number of operations it performs, rather than any set period of time like some other browsers. From KB175500:

As of Internet Explorer 4.0...the time-out is no longer a fixed value based on Windows messages. Internet Explorer now tracks the total number of executed script statements and resets the value each time that a new script execution is started...

So if you do a lot of quickly-executing script statements, you can still hit the limit in a somewhat short period of time.

Debugging and working around this is a matter of reducing the amount of work you do on each iteration (each $timeout call, in your case) until the problem goes away (since, sadly, IE8 doesn't support web workers).

like image 59
T.J. Crowder Avatar answered Mar 05 '26 12:03

T.J. Crowder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!