I have a webpage that includes 2 Javascript files. The second file requires the one before it. More specifically, in my 2nd Javascript file I am immediately using jQuery’s .ajax() method. Is it possible in a very edge case scenario that jQuery may not be ready when I go to use it?
Note: I do not want to use $(document).ready() and I do not want to use libraries such as require.js or head.js. I just want to have confidence that jQuery will be there when I go to use it, and that Javascript’s single-threaded nature will be respected even in edge cases.
Scripts included by
<script>with thesrcattribute are loaded serially. Therefore if you have the setup…
one-filemust finish downloading and executing before the document can continue parsing (i.e. before retrieval of the other file even begins). This is different with thedeferandasyncattributes, but it is probable that you are omitting those.If my answer is not peace-of-mind enough for you, I gleaned it from the HTML spec itself.