[whatwg] Script-related feedback

Diego Perini diego.perini at gmail.com
Sun Jul 25 03:57:52 PDT 2010


On Sun, Jul 25, 2010 at 3:25 AM, Steve Souders <whatwg at souders.org> wrote:

>  "Defer" doesn't achieve the desired behavior. The goal is "load this
> script after everything else in the page is done". Instead, defer'ed scripts
> get loaded immediately, thus stealing one of the few network connections
> from other (more important) resources.
>
>
If I recall correctly "defer" was meant as related to the script execution
not its loading, a totally different task.

I am not sure what I tried with "Cuzillion" is the correct way of testing
this specifically but adding an "in-line" script block with a 2 seconds
execute time at the end of the body also delay the deferred script of 2
seconds. To me this means the "defer" attribute will defer execution until
all other in-line scripts have finished run. Which, in turn, has noting to
do with information about the loading process and its timing.


> Here's an example:
>
> http://stevesouders.com/cuzillion/?c0=hj1hfft0_0_f&c1=bi1hfff2_0_f&c2=bi1hfff2_0_f&c3=bi1hfff2_0_f&c4=bi1hfff2_0_f&c5=bi1hfff2_0_f&c6=bi1hfff2_0_f&c7=bi1hfff2_0_f&c8=bi1hfff2_0_f<http://stevesouders.com/cuzillion/?c0=hj1hfft0_0_f&c1=bi1hfff2_0_f&c2=bi1hfff2_0_f&c3=bi1hfff2_0_f&c4=bi1hfff2_0_f&c5=bi1hfff2_0_f&c6=bi1hfff2_0_f&c7=bi1hfff2_0_f&c8=bi1hfff2_0_f&t=1280020727443>
>
> Notice that although the script is "defer" it gets loaded before the
> images. (The load time of the script is displayed at the bottom and is
> typically 200-500ms. However, each image takes 2000ms to download. If the
> script was truly deferred it should be downloaded some time > 2000ms. Since
> it's loaded earlier, it steals a network connection and causes one of the
> images to download later.)
>
> -Steve
>
>
>
To effectively defer loading of scripts (lazy loading) one should use the
"onload" event, that at least ensure cross-browser functionality.


Diego Perini



> On 7/23/2010 1:27 PM, Ian Hickson wrote:
>
> On Wed, 17 Mar 2010, Steve Souders wrote:
>
>
>  Given that it is possible to do this from script, how common is it for
> people to do it from script? If it's very common, that would be a good
> data point encouraging us to do this sooner rather than later.
>
>
>  6 of the top 10 US web sites load scripts after the load event: eBay,
> Facebook, Bing, MSN.com, MySpace, and Yahoo.
>
>
>  Do we know why they do this rather than use defer="", and whether
> defer="" would handle their use casess?
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100725/7004e56a/attachment-0002.htm>


More information about the whatwg mailing list