Async and Defer: list what happens when both attributes are used on a script tag. #95

Closed
adamcbrewer opened this Issue Mar 12, 2013 · 6 comments

Projects

None yet

3 participants

async as less support than defer, but async takes priority over defer.

Might also be worthwhile mentioning the implications if multiple scripts have these attributes; the order of script execution cannot reliably be determined when using async.

defer DOES NOT WORK unless your site completely doesnt care about IE9.

h5bp/lazyweb-requests#42

Thanks @paulirish – what a shame. Took a while to get through the issue you referred to, but it was worth it.

Would the blanket of "don't use" flag still stand for a synchronous Modernizr script in the head and a defer script in the footer that depended on it?

Additionally, would there be any benefit to a site using a single defer script which used some sort of require.js process for other scripts within?

I'll send @trevorburnham a link to your h5bp issue – recently read his book: Async Javascript. Unless I completely missed it, he might want to be aware of it.

@adamcbrewer adamcbrewer reopened this Mar 13, 2013

Thanks for cc-ing me on this, Adam. I was unaware of the defer bugs described in that thread. It sounds like it's safe to use defer with scripts that don't perform DOM manipulation, though.

It sounds like it's safe to use defer with scripts that don't perform
DOM manipulation, though.

True, though... that disqualifies nearly everything people commonly
reference with a script tag. :)

Would the blanket of "don't use" flag still stand for a synchronous
Modernizr script in the head and a defer script in the footer that depended
on it?

yes, unfortunately. it's a race condition you don't want to deal with.

single script tag with defer

sgtm. if you only have a single script tag then defer is fine (though async
does the same thing at that point)

On Wed, Mar 13, 2013 at 8:20 AM, Trevor Burnham notifications@github.comwrote:

Thanks for cc-ing me on this. I was unaware of the defer bugs described
in that thread. It sounds like it's safe to use defer with scripts that
don't perform DOM manipulation, though.


Reply to this email directly or view it on GitHubhttps://github.com/zenorocha/browser-diet/issues/95#issuecomment-14847394
.

Cheers for the answers Paul. If I come across this somewhere else I'll try update and link them through to the h5bp issue.

appreciated. :)
sorry it's not on a more definitive location but.... that's just where it
is.

On Wed, Mar 13, 2013 at 9:36 AM, Adam Brewer notifications@github.comwrote:

Cheers for the answers Paul. If I come across this somewhere else I'll try
update and link them through to the h5bp issue.


Reply to this email directly or view it on GitHubhttps://github.com/zenorocha/browser-diet/issues/95#issuecomment-14852531
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment