Reputation: 2757
Since I use defer and asynch attribute on my <script src="/all.js" asynch defer></script>
tags,
My script inside an HTML page cannot work because of jQuery (I load jQuery In defer).
So I have to use the window.onload
method from natif js.
Then I can use jQuery.
Problem is, window.load
make my script written inside my html too long to load, so imagine when I have to append element in jQuery, it takes a few seconds to do the job...
Any solution ? Maybe I don't understand the running of defer ad asynch..
Thank you in advance !
Upvotes: 0
Views: 269
Reputation: 2307
async and defer scripts begin to download immediately without pausing the parser. The difference between async and defer centers around when the script is executed.
async script executes at the first opportunity after it is finished downloading and before the window’s load event.
defer scripts are guaranteed to be executed in the order they occur in the page. That execution starts after parsing is completely finished, but before the document’s DOMContentLoaded event.
Upvotes: 1