views:

53

answers:

2

On a page that I visit, it has a slow-loading external script that occasionally takes so long that the page is basically unusable. Disabling this script entirely removes some functionality, but it's better than nothing.

Is there a way I could use greasemonkey to cancel the script? I know I could use NoScript, but I wanted to give it a chance (with a JS timeout).

I kind of doubt it (since Greasemonkey doesn't even seem to run scripts until the page has finished loading), but I wanted to check to be sure

+1  A: 

Quite possibly not. Since Greasemonkey runs last, you can't remove the tag before it happens, and I'm pretty darn sure that no form of Javascript will let you kill an HTTP request of any sort.

Have you tried just plain removing the script tag before it finishes loading completely, though? I suspect that in some browsers that might do the trick, since I think Greasemonkey scripts run on DOMReady, not onload.

Matchu
Yeah I tried that. I can't even get my script to run when the external script doesn't load - the page just hangs waiting on it, and GM doesn't kick in until I hit the stop button. Thanks!
rampion
@rampion - odd, since I confirmed that Greasemonkey is, in fact, [on DOMContentLoaded](http://wiki.greasespot.net/DOMContentLoaded). Of course, I haven't had to deal with much messy stuff before - I guess scripts are required to load before the DOM is considered ready =/
Matchu
+1  A: 

Is that script located at a different domain (that's not used by (almost) anything else)?

If so, you can block access to it by changing your hosts file; e.g., see http://someonewhocares.org/hosts/

Marcel Korpel