Re: [whatwg] Deferring javascript download and execution until after onload

On Tue, Sep 18, 2012 at 1:28 AM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> On Tue, Sep 18, 2012 at 10:26 AM, Rick Waldron <waldron.rick@gmail.com> wrote:
>> On Tuesday, September 18, 2012 at 2:54 AM, Jonas Sicking wrote:
>>> There has been discussions about implementing a "noexec" attribute on
>>> <script> which would just load the script but instead of evaluating it
>>> as soon as it's available, simply fire the "load" event. There would
>>> also be an additional .execute() function on the script which would
>>> permit executing the script after it has been loaded.
>>
>> What happens to the execute() function after the first time it's called? Is it magically removed? Is it nulled? If not, what happens when it's called twice for the same script?
>
> It presumably sets the "has run" flag on the <script>, so the second
> call simply does nothing.

Yeah, it'd set the "has run" flag.

If calling .execute() on a "has run" script is a no-op or causes an
exception to be thrown I don't really have a strong opinion about. We
would need to pick one and document it. If people have strong opinions
one way or another I'm all ears.

/ Jonas

Received on Tuesday, 18 September 2012 09:00:03 UTC