On Jan 13, 12:58 pm, "T.J. Crowder" <
t...@crowdersoftware.com> wrote:
> > I usually try to eliminate as much of irrelevant prototypeism as
> > possible when creating a testcase : )
>
> Fair 'nuff, but I'd still use something other than inline to allow for
> browsers being difficult about the closing body tag and DOM rendering
> time. Probably me being paranoid. Perhaps (shock and horror) DOM0
> window.onload stuff, image loading not being an issue:
>
> <script type='text/javascript'>
> window.onload = function() {
> alert('Found ' + $$('.wrapper .inner').length);});
>
> </script>
This is perfectly fine of course : )
>
> > at the time when <body> is definitely loaded
> > and parsed.
>
> Is it, definitely? Within the tag? (Serious question, you know more
> about this stuff than I do.)
AFAIK, <script> elements are loaded and parsed sequentially (just like
most if not all other elements - exception being, maybe, <meta> tag
which has "Content-Type" and so might be parsed as early as
possible).
When a <script> element (the one before closing </body> tag) is
downloaded, parsed and evaluated, all of the DOM elements before it
should be present in DOM (that includes <body> of course)
I'm far from an expert in this field, but am pretty sure this is
what's happening : )
[...]
--
kangax