[whatwg] script postonload
Boris Zbarsky
bzbarsky at MIT.EDU
Wed Feb 10 11:26:55 PST 2010
On 2/10/10 1:55 PM, Steve Souders wrote:
> Being able to replicate the behavior in JavaScript is not a valid reason
> to reject the proposal.
No, but it _is_ a reason to carefully consider the complexity the
proposal introduces against the possible benefits of the proposal and to
perhaps examine the cases where content right now does this thing that
we're presumably proposing to make easier.
> For example, all the behavior of DEFER and ASYNC can be replicated using JavaScript
That's not the case, actually. The behavior of DEFER (eager load start,
deferred script execution, not blocking the parser or other scripts
while loading) cannot in fact be replicated using JavaScript in a
cross-browser manner. The behavior of ASYNC (and in particular its
allowing scripts to run in order other than DOM insertion order,
combined with the eager loading it triggers, not blocking other scripts,
and execution when the load is done) can't be replicated cross-browser
either, unless I'm missing something.
> Adding "DEFER" is significantly simpler than adding a load handler that
> dynamically appends a SCRIPT element to the DOM.
And has a different behavior from such a load handler. On the other
hand, a script that instead of having this structure:
foo();
bar();
has this structure:
window.addEventListener("load", function() {
foo();
bar();
}, false);
(and the IE version thereof) does in fact have behavior identical to
your proposal, at least insofar as your proposal has a defined behavior
at the moment. And works in all browsers modulo the
addEventLister/attachEvent difference.
-Boris
More information about the whatwg
mailing list