html preload和prefetch有什么区别? [英] What are the differences between html preload and prefetch?

查看:82
本文介绍了html preload和prefetch有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Preload和prefetch都用于预先请求资源,以便以后可以快速加载资源.看来我可以互换两者

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

< link rel ="preload" href ="foo.js" as ="script">

< link rel ="prefetch" href ="foo.js">

没有任何区别.

它们有什么区别?

推荐答案

Addy Osmani写道详细介绍此内容的文章,但简短的版本是:

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

preload是一种声明式提取,可让您强制浏览器执行以下操作:在不阻止文档加载的情况下请求资源事件.

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向浏览器提示可能需要资源,但是代表们决定是否以及何时加载它是一个好主意浏览器.

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.

这篇关于html preload和prefetch有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆