Re: The synchronous load event is trouble

On Nov 26, 2009, at 14:13, Henri Sivonen wrote:

> In Gecko, in the XML tree builder, the event is implemented as an event that fires synchronously when the </svg> end tag is parsed. I haven't implemented this event at all in the HTML5 parser in the hope that the SVG WG makes it undesirable characteristics go away.
> 
> I think the definition of the event has at least the following three problems:
> 
> 1) The firing of the event is synchronous with the parse. This is highly unusual. I'm not aware of any other standards-based feature requiring an event to be dispatched synchronously with the parse. Gecko has some non-stardards-based analogous behaviors, but, as I understand it, those behaviors cause scripts to run either from the task queue or from a deferred execution mechanism that isn't fully synchronous but isn't the task queue, either. Having scripts run as the side effect of the parse is generally trouble. It's impossible to eliminate </script> running scripts as a side effect of the parse, but I think we should get rid of all the other cases, so that parsing can be optimized with the assumption that only </script> may cause synchronous script execution (which requires the parser to go into a state that's safe for script execution).
> 
> 2) The event is defined to be fired at a particular point relative to parse but also relative to network activity. Scripts already have to block the parser for legacy reasons. However, all blocking of the parser due to external resources is bad for performance, so it would be desirable to allow styles to load asynchronously with the parse. As written, the spec text seems to establish </svg> as a point where the parser potentially has to yield to the event loop if there are pending style sheet loads. (I don't know how cross-resource 'use' works, but it seems trouble if those don't attach asynchronously.)

Firefox trunk now fires the SVG load event asynchronously when the </svg> end tag is processed in both XML and HTML. The event is no longer fired for SVG elements other than <svg>. The event now fires regardless of an 'onload' attribute on the <svg> element, so it works with addEventListener(). As before, nothing is done to wait for any external resource loads.

It seems to me that Opera already fires the event asynchronously.

-- 
Henri Sivonen
hsivonen@iki.fi
http://hsivonen.iki.fi/

Received on Wednesday, 9 June 2010 13:37:05 UTC