Tuesday, January 3rd, 2006
Dave Flanagan asks: when do DOM elements become available to embedded scripts?
(i)f you have an element <div id=”foo”>, when can you call getElementById(‘foo’) and be sure that you’ll get a valid result?”
It should be so simple!
Most people rely on window.onload, though that’s usually later than need be, and Dave comments that it’s not even guaranteed anyway; his main issue here seems to be that the specs are ambiguous and the browsers are inconsistent. Knowing more about this could lead to some nice performance optimisations. Dave points to Dean Edwards’ neat hacks, which are very useful if browser-dependent. Dave’s seeking feedback on these issues from anyone in the know.
Posted by Michael Mahemoff at 7:22 pm