[whatwg] When do scripts execute? (4.3.1)

Jonas Sicking jonas at sicking.cc
Thu Jan 15 15:09:18 PST 2009


On Thu, Jan 15, 2009 at 8:28 AM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> Kartikaya Gupta wrote:
>>
>>  sn = document.createElement( 'script' );
>>  sn.setAttribute( 'type', 'text/javascript' );
>>  document.body.appendChild( sn );        // this *should* run an empty
>> script block and do nothing
>
> That looks like a bug in the spec to me.  Empty scripts with no @src are not
> executed when inserted into the DOM, and are executed if they ever become

At least in the mozilla implementation, though would be interested
what other implementations do. The reason was that I wanted to support
the following usage pattern:

s = document.createElement('script');
document.body.appendChild(s);
s.src = "http://foo/bar";

Note that in IE, you can set the src attribute any number of times and
every time it will download and execute the new script, even when the
old src value is the same as the new.

/ Jonas



More information about the whatwg mailing list