How do I prevent $ .getScript from executing document.ready content?

I want to call a function that is in another JavaScript file.

function foo(){
    //before $.getScript
    $.getScript('otherScript.js', function() { 
        otherFoo();
    });
    //after $.getScript
}

      

But this will execute the entire $ (document) .ready () part of otherScript.js before calling the otherFoo () function. How can I disallow the $ (document) .ready () call and only call the otherFoo () function?

+3


source to share


1 answer


You cannot do this.

It will run the entire file. If you don't want to run anything, then put everything in otherScript.js functions in functions.



What you want to do is not possible without writing a separate parser.

+3


source







All Articles