Re: Executing script-inserted external scripts in insertion order

> >> Yeah, I don't know. I don't mean to be negative, it just seems
> like a
> >> really obscure feature.

I think it's more obscure to make async have no effect on script-inserted external scripts while it has an effect on parser-inserted external scripts than to make it have the same effect on both. (Well, not exactly the same, since non-async parser-inserted external scripts maintain order relative to parser-inserted inline scripts, but the ideas being discussed for script-inserted scripts don't involve non-async script-inserted external scripts blocking script-inserted inline scripts.)

> > I think from a user education point of view, I would actually argue
> > that keeping scripts ordered is a better solution. Any time you use
> > async script you are exposing yourself to race conditions. If
> > scripts
> > load with a different speed at a users computer than at yours, then
> > you are running the risk that scripts are running in a different
> > order
> > than what you have tested with. This could easily happen if all the
> > scripts have been cached in your browser, but won't be for a user
> > that
> > visits for the first time.
> >
> > So any time async scripts are used, that needs a significant amount
> > of
> > understanding and care by the developer. This includes if the script
> > is async because it was inserted using the DOM.
> >
> > So I'd rather that a user that doesn't understand what async and
> > defer
> > is *don't* use them, and that they in that case get ordered,
> > non-racy,
> > behavior.
> 
> +1 on this perspective. I think that makes a lot of sense. Of course,
> the
> key point is that a developer *in the know* can opt-in to the other
> behavior
> as desired.

I agree that making script-inserted external script maintain order among themselves by default and making async=true opt into unordered as-soon-as-possible execution would be a virtuous solution on almost all counts:
 * The safe behavior would be the default for authors who aren't prepared to handle the less safe behavior (once IE and WebKit versions that have the old unsafe default have faded away)
 * It would allow all browser to Support Existing Content (though IE and WebKit would also have to continue to support script/cache preloading to Support Existing Content)
 * The default would go the same way (async=false) for both script-created and parser-created scripts.

The big question is if we can get to interop via this route. That depends on whether IE and WebKit are willing to change their default behavior for script-inserted external non-async scripts. Are they?

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

Received on Thursday, 14 October 2010 07:48:49 UTC