[whatwg] <video> ... <script> race condition

Ojan Vafai ojan at chromium.org
Sat May 14 15:24:33 PDT 2011

On Sat, May 14, 2011 at 8:49 AM, Eric Carlson <eric.carlson at apple.com>wrote:

> On May 13, 2011, at 4:35 AM, Philip Jägenstedt wrote:
> > I wasn't asking how to work around the problem once you know it exists, I
> was wondering if any browser vendors have done anything to make this problem
> less likely to happen on pages like http://html5demos.com/video that don't
> do the right thing?
> >
>   WebKit has not.
>  It seems to me that the right way to "fix" the problem is let people know
> it is sloppy code, not to figure out a way to work around it.

If someone proposed a workable solution, browser would likely implement it.
I can't think of a backwards-compatible solution to this, so I agree that
developers just need to learn the that this is a bad pattern. I could
imagine browsers logging a warning to the console in these cases, but I
worry that it would fire too much in today's web.

It's unfortunate that you need to use an inline event handler instead of one
registered via addEventListener to avoid the race condition. Exposing
something to the platform like jquery's live event handlers (
http://api.jquery.com/live/) could mitigate this problem in practice, e.g.
it would be just as easy or easier to register the event handler before the
element is created.


More information about the whatwg mailing list