The browser will most likely load both scripts in parallel (unless the script is already cached), but the execution order is guaranteed to be in order. Moreover, the part of the page that is behind the script will not become part of the script until the script has loaded and executed. This ensures that you can safely include libraries in your code and expect them to be present when you run the main script.
As already noted, you should not use script tags with either src or your own content.
<script src = "http://path.to.a.cdn/jquery-latest.min.js"></script> <script> $(function(){ ... }) </script>
You can override this behavior using async or defer .
Set this boolean attribute to indicate that the browser should, if possible, execute the script asynchronously. It does not affect embedded scripts (i.e., scripts that do not have the src attribute).
Move
This Boolean attribute is set to indicate to the browser that the script is intended to be executed after the document has been parsed. Since this feature has not yet been implemented by all other major browsers, authors should not assume that script execution will actually be delayed. Never call document.write() with a defer script (since Gecko 1.9.2, this will deflate the document). The defer attribute should not be used for scripts that do not have the src attribute.
No attribute works in IE prior to IE 10, so don't rely on a script that doesn't execute anyway.
Compatibility Chart: async ; defer
Link: https://developer.mozilla.org/en/docs/Web/HTML/Element/script
source share