0

is it possible to prevent further execution of javascript?

I include some javascript scripts with php in a header (with echo ''), but there are coming some other scripts later in the page which i can not always control, so it could be that my before included (with ) mootools javascript get later overwritten by another included mootools (which then possible is an older version, or is not complete etc.)

so is there a way that I can stop the js at one point so that later js code will not be executed?

kind of like the die(); function in php, but without that it stops the page from being loaded.

1
  • 4
    no, there is no way to either stop javascript via javascript nor to prevent further scripts being brought into a page, time to refactor and clean up. Commented Oct 28, 2010 at 19:31

1 Answer 1

2

doesnt really exist. but you can put everything into a function and "return;" any given time to exit the function which would stop the execution of the rest of the code within the function.

super simple example in standard JS:

function init() {
    if(something happens) {
         return;
    }
}
init();

in terms of stopping the browser from executing other scripts within the page - not possible.

Sign up to request clarification or add additional context in comments.

2 Comments

hm doenst really help, because i can not include the mootols library and other external classes in a function :-) in fact there is something called window.stop(); but this is like clicking the stop loading button, and this will stop loading the page... is there a way to prevent that one already loaded mootools libraray will be overwritten by a later included one?
sure you can, just use something like require.js ;) - sorry for being 2 years late on this haha.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.