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

At 10:40 AM 12/1/2004 -0600, Boris Zbarsky wrote:

>Jim Ley wrote:
>>Removing, inserting or altering script elements once the document has 
>>been loaded has no effect.
>
>May I ask why there is this clause?  The "altering" and "removing" part 
>makes sense, but in other markup languages creating a brand-new <script> 
>and inserting it into the document will execute that script...

I don't think HTML or XHTML spec really defines it. And I think it is a bad 
idea to do it, it is probably an artifact of a particular way of 
implementing it rather then explicit design. What are use cases for that? 
If new script needs to be executed at runtime, just execute script through 
your language-dependent mechanisms explicitly. 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 (and I might not even know that they are in the 
branch). Also, if you really want the behavior of execution on insertion, 
you can always register DOM insertion mutation even listener that would do 
it for you; but if UA executes on insertion, you are stuck with it and 
cannot turn it off.

Peter


>-Boris

Received on Wednesday, 1 December 2004 17:52:33 UTC