[whatwg] should we add beforeload/afterload events to the web platform?
Roman Rudenko
roman at mobify.com
Thu Jan 12 18:23:51 PST 2012
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
More information about the whatwg
mailing list