Re: LC Comment - Script & Progressive Rendering / Multiple Pages

Peter Sorotokin wrote:
> I don't think HTML or XHTML spec really defines it.

You're correct, it does not.  There's a de-facto standard, not a de-jure one.

> If new script needs to be executed at runtime, just execute script 
> through your language-dependent mechanisms explicitly.

I want to dynamically execute the script at http://foo at runtime.  Using 
language-dependent mechanisms in ECMAScript I have to somehow load the data into 
a string (dealing with character encodings in the process) and then call eval() 
on it?  Using a <script> node, I just set the src attribute and insert the node.

This is a relatively common use case on the web, especially for working around 
UA bugs by executing slightly different scripts based on UA-sniffing or 
object-sniffing (though most pages use document.write() instead of creating 
nodes via DOM, the concept is the same and document.write() is not available in 
SVG).

> If script is executed on insertion, a lot of funny issues arise. For instance, if I 
> remove a branch from a tree and then insert it somewhere else all the 
> scripts in that branch will be reexecuted

Not necessarily.  See the algorithm described in my last response to Jim.

-Boris

Received on Wednesday, 1 December 2004 17:57:40 UTC