3

I'm viewing this website that has a client side javascript error caused by the scripts being loaded in the wrong order. Problem is I don't own this source, but I really need to use the site ASAP.

Is there a browser/browser plugin that will let me fix this in the browser and let me continue to use the page? The problem is that since this is loaded in the head element, if I modify the html the JS error has already occurred. And if I refresh the changes (at least in chrome) my local modifications have disappeared.

Specifically, the html is like this:

<script language="javascript" src="/scripts/util.js" type="text/javascript"></script> <script language="javascript" src="/scripts/scriptaculous/prototype.js" type="text/javascript"></script> <script language="javascript" src="/scripts/scriptaculous/scriptaculous.js" type="text/javascript"></script> 

And to fix the bug, it would need to be like this:

<script language="javascript" src="/scripts/scriptaculous/prototype.js" type="text/javascript"></script> <script language="javascript" src="/scripts/scriptaculous/scriptaculous.js" type="text/javascript"></script> <script language="javascript" src="/scripts/util.js" type="text/javascript"></script> 

Notice how the util.js moved to the bottom.

1 Answer 1

1

You might be able to do this by making a userscript that loads the javascript you need in the order you need it. A userscript can execute essentially any arbitrary javascript on the page, including loading other javascript. The only concern would be whether the browser executes the userscript before or after loading the other scripts on the page. This stack overflow question seems to imply (2nd answer) that there's a way to do this.

A simple userscript might use the aforementioned method and the document.write command to insert a new <script> element as needed before the page parses any other javascript.

4
  • Thanks for the help. This is the path I'm going down. Is this question better suited for stack overflow? Commented Dec 1, 2013 at 7:17
  • 1
    @tieTYT I think the question is OK for SU since you were initially asking if your browser could do something, and there could be other answers that aren't programming-related. If you run into additional problems along the way, I'd suggest searching on SO first, and then asking a question over there if you need to. Commented Dec 1, 2013 at 7:22
  • 1
    Unfortunately a user-script won’t work because Chrome doesn’t support document-start for the run-at key, only document-end. Commented Dec 3, 2013 at 6:25
  • @Synetech hm. Well I'm assuming the user could probably use Firefox just for this one page, but that's a good point. Commented Dec 3, 2013 at 9:02

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.