What are the differences between html preload and prefetch?

前端 未结 4 586
旧时难觅i
旧时难觅i 2021-02-05 09:40

Preload and prefetch are both used to request resources in advance so that later resource loading can be quick. It seems that I can interchange the two

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-05 09:54

    Addy Osmani wrote an article that goes into the details of this, but the short version is:

    preload is a declarative fetch, allowing you to force the browser to make a request for a resource without blocking the document’s onload event.

    Prefetch is a hint to the browser that a resource might be needed, but delegates deciding whether and when loading it is a good idea or not to the browser.

提交回复
热议问题