Search code examples
phpjavascriptmootools

stopping javascript from getting executed


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.


Solution

  • 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.