asynchronous javascript loading/executing
Posted
by
Kai
on Stack Overflow
See other posts from Stack Overflow
or by Kai
Published on 2011-01-08T01:38:45Z
Indexed on
2011/01/08
1:53 UTC
Read the original article
Hit count: 479
JavaScript
In this post, asynchronous .js file loading syntax, someone said, "If the async attribute is present, then the script will be executed asynchronously, as soon as it is available."
(function() {
var d=document,
h=d.getElementsByTagName('head')[0],
s=d.createElement('script');
s.type='text/javascript';
s.async=true;
s.src='/js/myfile.js';
h.appendChild(s);
}()); /* note ending parenthesis and curly brace */
My question is, what does "the script will be executed asynchronously" mean? Will this script be executed in a different thread from other javascripts in the page? If yes, should we worry about synchronization issue in the two threads?
Thanks.
© Stack Overflow or respective owner