[whatwg] comments on SCRIPT ASYNC and DEFER
Jonas Sicking
jonas at sicking.cc
Wed Feb 10 12:21:28 PST 2010
On Wed, Feb 10, 2010 at 10:49 AM, Steve Souders <whatwg at souders.org> wrote:
> Two common scenarios where scripts aren't put at the bottom:
> - Having talked to web devs across hundreds of companies it's often the
> case that they control a certain section of the page. Inserting content
> outside of that section requires changing so much infrastructure, they skip
> the optimization.
> - 3rd parties have no control over where their snippet is placed in the
> content owner's page. Providing a snippet that contains "DEFER" will
> guarantee they don't block the main page's content.
I think there are use cases both for wanting to start fetching as soon
as possible, and to start fetching at the end in order to avoid
blocking.
However defer is already implemented in IE and Firefox as a way to
start fetching as soon as possible, but only execute at the end, so
I'm reluctant to change it at this point.
Instead, if the use cases are strong enough, I think we need to
introduce another mechanism for delaying a <script> to get loaded
until after the 'load' event has fired. I think it's an interesting
idea to add a 'postonload' attribute to all resources, such as
<script>, <img> and <link rel=stylesheet> (though the maybe the name
could be better).
/ Jonas
More information about the whatwg
mailing list