asynchronous - how to load jquery and its dependencies script asyncronously -
asynchronous - how to load jquery and its dependencies script asyncronously -
i having issue loading jquery asynchronously. can see if load javascript doesn't depend upon other library file work loading jquery script , library file async doesn't work , throws error saying $ not defined
below script lies in head tag
<script async src="../js/jquery/jquery-1.10.1.min.js"> </script> <script async src="../js/vendor/modernizr-2.8.2.min.js"></script> <script async src="../js/asynchronous-resources/2014-06-03-asynchronous-resources.js"> </script> below main.js lies in footer above closing of body tag.
<script async src="../js/main.js"></script> above script throwing error. how load jquery , dependencies asynchronously.
any help appreciated.
thanks in advance.
there couple of options can try
if want execute script in same order specified in html defer need.
async , defer scripts begin download without pausing parser. difference between async , defer centers around when script executed.
async script executes @ first chance after finished downloading , before window’s load event.
defer scripts guaranteed executed in order occur in page. execution starts after parsing finished, before document’s domcontentloaded event.
since using modernizr, perhaps can seek modernizr.load
or utilize require.js
jquery asynchronous
Comments
Post a Comment