I use async attribute with the simplest way :
<script async type="text/javascript" src="path/jquery-1.10.2.min.js"></script>
for all .js in my page but problem is that once it loads good and once no.
Especially when i refresh page .js scripts doesn't load.
As soon as i delete async, everything works fine but it is no solution.
Someone know, where problem could be ?
Thanks
-
The script still loads, it just most likely loads after you need it to load (dependent scripts like jQuery plugins) end up loading before jQuery is available.Adam Jenkins– Adam Jenkins2015-04-20 12:29:47 +00:00Commented Apr 20, 2015 at 12:29
Add a comment
|
1 Answer
From the spec:
If the async attribute is present, then the script will be executed asynchronously, as soon as it is available.
That means that, depending on how fast the browser manages to download it, it might be executed before or after the other scripts you have that depend on it.
Don't use async when you are loading a script that other scripts will depend on.