keithclark / selectivizr

selectivizr is a JavaScript utility that emulates CSS3 pseudo-classes and attribute selectors in Internet Explorer 6-8.
1.71k stars 247 forks source link

Fix potential "Stop running this script" errors in IE. #51

Closed gcpantazis closed 7 years ago

gcpantazis commented 11 years ago

As we scaled a site using Selectivizr to production levels of DOM content, we noticed that IE7 (and occasionally IE8, depending on the resources) started throwing "Stop running this script" errors. I traced it back to the applyPatches() method, which in our case was extremely complex; we had a domPatch length of near 800.

Since all of this code executes in the same loop/closure, the more you throw in it the more likely you are to see this error. Our solve was to first wrap the for-loop's code in a setTimeout with a 0ms timer (basically _.defer() from underscore, see http://underscorejs.org/#defer and http://www.picnet.com.au/blogs/Guido/post/2010/03/04/How-to-prevent-Stop-running-this-script-message-in-browsers), and wrap that with a self-executing function to preserve the iterator once the timeout executes.

Hopefully this is an easy add, but let me know if additional info / tests are required. Thanks!

gcpantazis commented 11 years ago

@keithclark, just wanted to ping you on this one; I've had a few people reach out to say this fixed problems they were seeing in their projects, so hopefully it's good to add to the source.

christopinka commented 10 years ago

Worked very nicely. Thanks. Solves problem of supporting legacy Microsoft browser.

thomashigginbotham commented 10 years ago

This definitely solved the problem on our end. It needs to be merged ASAP.

flaviotsf commented 10 years ago

+1 this patch fixed our IE8 issues as well.

larryprice commented 10 years ago

++ This patch fixes our issue.

dominikwilkowski commented 10 years ago

:+1: why is this not merged?

Tg7z commented 9 years ago

Probably because there hasn't been a commit to this repo since Nov 2012

+1 for this fix though

samasmith commented 9 years ago

+1 - Where's the petition to get this merged?

wwwmonkey commented 9 years ago

+1 @gcpantazis Thanks mate, great work.

evankleist commented 9 years ago

+1

Would love to see this get merged

hellojebus commented 9 years ago

+1 Worked for me for a large production site. (aka saved my life)

exside commented 9 years ago

+1!

dixhuit commented 9 years ago

Just fixed a very similar issue thanks to this PR. Is there a good reason why this hasn't been merged?

corysimmons commented 8 years ago

@keithclark disappeared so I'm going to try and maintain this project at https://github.com/corysimmons/selectivizr2

Would you please reopen/rebase your PR over there?

gcpantazis commented 7 years ago

Hey all, given that this project is pretty dang dead I'm going to go ahead and close this out. If anyone wants to own it / work with @corysimmons on merging into his fork please feel free to cherrypick my patch. 👋