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

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

From: Simon Pieters <simonp@opera.com>
Date: Thu, 12 Jan 2012 11:16:30 +0100
Message-ID: <op.v7yutsp8idj3kv@simon-pieterss-macbook.local>
On Wed, 11 Jan 2012 15:51:47 +0100, Boris Zbarsky <bzbarsky at mit.edu> wrote:

> On 1/11/12 6:59 AM, Simon Pieters wrote:
>> http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1297
>>
>> Might not be cross-browser yet (e.g. Opera seems to run the image's
>> onload handler), but should work per spec I think. Well, the load can't
>> be prevented if it's speculatively loaded it before the script has
>> executed, but maybe that's fine for the use case.
>
> This also doesn't prevent rendering (which can easily start before  
> DOMContentLoaded), doesn't prevent execution of script in the document  
> that's being loaded, etc.

Sure it does (or at least should, and does in Firefox). Note that it  
removes the root element when the script element is executed, not at  
DOMContentLoaded. It does the transformation and puts the root element  
*back* at DOMContentLoaded. Scripts don't run when parsed into the other  
document since it is a different document than the one the HTML parser  
runs on. They don't run when the root element is put back, either, since  
they are marked as already-executed, I think.

The only way something could be rendered with the above script before it  
runs is in Opera with DSE enabled.

> Again, the hard part of doing a transformation on HTML is not doing the  
> transformation; it's preventing the transformation source document from  
> being treated "as usual".

-- 
Simon Pieters
Opera Software
Received on Thursday, 12 January 2012 02:16:30 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:39 UTC