Reputation: 645
Preload: 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.
Defer: The "defer" preloads during HTML parsing and will only execute it after the parser has completed.
I cant understand the differences in both concepts. Both fetch stuff asynchronously without blocking the parser and afterwards both can be executed when the parser is done.
So is there any difference at all?
Upvotes: 9
Views: 2609
Reputation: 46
You use "defer" for scripts that need to be executed after the HTML document is parsed, and "preload" when you want to load resources much earlier.
Upvotes: 0
Reputation: 1
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. Defer: The "defer" preloads during HTML parsing and will only execute it after the parser has completed.
Upvotes: 0