Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Clarify preload with relation to async and defer? #13

Closed
marcoscaceres opened this issue Nov 3, 2014 · 7 comments
Closed

Clarify preload with relation to async and defer? #13

marcoscaceres opened this issue Nov 3, 2014 · 7 comments

Comments

@marcoscaceres
Copy link
Member

The spec says:

The preload hint can be used by the application to initiate early fetch, but delay processing of the received response - e.g. fetch a CSS stylesheet and apply it at some later time, fetch a JavaScript asset and execute it later, and so on. Preload fetches do not block the document load event and allow the application to determine which resources are applied, when they are executed, and in which order.

Maybe clarify how this differs from async and defer in the case of scripts?

@ashumeow
Copy link

ashumeow commented Nov 3, 2014

The "async" preloads during HTML parsing and will pause the HTML parser to execute it when it has finished.
The "defer" preloads during HTML parsing and will only execute it after the parser has completed.
("it" refers to data that could in the form of text, images, audio, video)

@marcoscaceres
Copy link
Member Author

@ashumeow, I was hoping to see something like what you wrote in the spec itself (in non-normative prose) - in that it clarifies what this spec brings to the table :)

@ashumeow
Copy link

ashumeow commented Nov 5, 2014

@marcoscaceres Thanks bro! :)

@igrigorik
Copy link
Member

This text now lives in preload, which should address above feedback: http://w3c.github.io/preload/#early-fetch-and-application-defined-execution

@Legends
Copy link

Legends commented May 26, 2020

@ashumeow This means, in case of scripts defer equals preload ?

@torian257x
Copy link

@ashumeow This means, in case of scripts defer equals preload ?

afaik yes.... just that preload doesn't have a useful fallback. Bummer.

@AliN11
Copy link

AliN11 commented Sep 6, 2022

@ashumeow This means, in case of scripts defer equals preload ?

I don't think so. defer scripts are executed immediately after DOM is parsed. preload doesn't guaranty that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants