[whatwg] Deferring javascript download and execution until after onload

Andy Davies dajdavies at gmail.com
Wed Sep 19 01:14:33 PDT 2012


On 18 September 2012 07:54, Jonas Sicking <jonas at sicking.cc> 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.
>
> This has mostly been discussed in a performance context where people
> has expressed interest in loading scripts, while only waiting to
> execute it until needed in order to avoid the costs involved in
> parsing and executing the script.
>
> So far Hixie hasn't been interested in putting this into the spec
> though, due to, as I understand it, not being convinced that it's
> needed from a performance point of view.
>
> I'd personally be interested to see it implemented since people
> clearly do load scripts dynamically and it would seem common for such
> scripts to have dependencies on each other, which means that you have
> to be able to execute them in a certain order.
>

Thanks for the details...

>From a performance point of view I'm encouraging my clients (and
others are too) to load third-party content asynchronously and where
possible after onload.

I've seen big variations in download times from third-parties like
Facebook and Twitter (measured using synthetic monitoring that
generates waterfalls for each page load) and of course these affect
when the onLoad event fires.

Cheers

Andy



More information about the whatwg mailing list