W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2012

[whatwg] should we add beforeload/afterload events to the web platform?

From: Roman Rudenko <roman@mobify.com>
Date: Thu, 12 Jan 2012 18:23:51 -0800
Message-ID: <CAOtd2HWYpipSgG0EP02+gaRRo0_H+-iW=fof6su2vCvN2P2dqg@mail.gmail.com>
On Thu, Jan 12, 2012 at 11:32 AM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
>> For example, @media-controlled mobile view of a page
>> originally designed for desktop will typically include all desktop
>> assets. beforeload can fix that, as desktop resource loads could be
>> cancelled or even replaced with mobile-specific ones without complete
>> HTML reconstruction.
>
>
> Except they can't, because beforeload fires after the load has started in
> many cases, right?

Blocking is possible under some circumstances. Webkit differentiates
between normal parser and speculative parser. Speculative parser is
launched only if normal parser is blocked on execution of a script.
So, one could use beforeload to block resources in Webkit, for as long
as no synchronous scripts are allowed to slip through. Unfortunately,
one runaway script blocks the parser and spoils blocking for anything
after itself.
This might not work as nicely in Firefox, which, according to Boris,
does not maintain separation between main and speculative parser.

Even if that does not work, beforeload can prevent processing of
needlessly fetched resource (which makes it behave more like
'beforeprocess', suggested by Boris).


-- 
Roman Rudenko
Received on Thursday, 12 January 2012 18:23:51 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:10 UTC