[whatwg] The Attributes of the script element
Boris Zbarsky
bzbarsky at MIT.EDU
Fri Jul 30 07:46:11 PDT 2010
On 7/30/10 4:33 AM, zhao Matt wrote:
> Obviously, the book thinks Client-side JavaScript is (or behaves as if
> it is) *single-threaded*.
> However,
> HTML5 spec states 'the user agent must immediately execute the script
> block, even if other scripts are *already* executing.',
> Does it imply that scripts can be run in parallel?
This seems to be a common misconception.
Being single-threaded doesn't mean things can't be _reentrant_. So if
you have a script running and that script inserts a <script> node with a
textnode child into the document, the script contained in that textnode
will be executed immediately even though there is already a script
running. This will happen before control returns to the original script
from the appendChild call.
Whether this setup maps to "run in parallel" in your head, I don't know.
> "Running a script: When a script element is to be run, the user agent
> must act as follows:..."
> The process includes 9 steps, but I don't sure which step will take the
> attribute 'async' into consideration.
Um... Step 9, which is the only one that mentions it, no?
Having an "async" attribute prevents a script from taking the first two
options in that step.
-Boris
More information about the whatwg
mailing list