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

At 11:57 AM 12/1/2004 -0600, Boris Zbarsky wrote:
>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?

Yes. Use URIRequest and eval.

>   Using a <script> node, I just set the src attribute and insert the node.

I think this usage is a hack.

>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).

URIRequest and eval works just as well for that.


>>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.

Yes, I saw it; this implies that script element has some sort of a hidden 
state that has to be managed it some way. I'd rather not introduce it.

Peter


>-Boris

Received on Wednesday, 1 December 2004 19:44:59 UTC