Does it make sense to import javascript?
I have an aspx page and import jQuery, jTemplate and Flexigrid
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="Scripts/flexigrid.pack.js" type="text/javascript"></script>
<script src="Scripts/jquery-jtemplates.js" type="text/javascript"></script>
<script src="Scripts/jquery.json-1.3.min.js" type="text/javascript"></script>
Is the order of imports higher?
source to share
Yes, as long as the script uses whatever is defined by the other script at boot time. Each script is loaded and evaluated in order, synchronously. (Downloads can be parallel if the browser wants, but they will be evaluated in order if the attributes defer
orasync
were not specified and supported by the browser.)
So, for example, suppose that at least the last two scripts use the character jQuery
defined by the first script, and so they must appear after it, or you see errors like ReferenceError: jQuery is not defined
.
The order of the unrelated scripts doesn't matter, but where they build on top of each other (as in this case) it does.
source to share