javascript – LINK元素是否同步加载?
作者:互联网
如果我有以下HTML5文档:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FOOBAR</title>
</head>
<body>
<link rel="stylesheet" href="/largefonts.css">
<script src="onload.js"></script>
</body>
</html>
请问< link>标签加载是否同步,以便在执行onload.js脚本时,应该在浏览器中加载字体?
请注意,我不是在询问字体是否已应用于任何DOM节点,我只想知道它们是否已加载到内存中.
解决方法:
获得< link>的过程资源在corresponding section of the HTML5 spec中描述,答案如下:
User agents may opt to only try to obtain such resources when they are needed, instead of pro-actively fetching all the external resources that are not applied
然而,
The [
<link>
] element must delay the load event of the element’s document until all the attempts to obtain the resource and its critical subresources are complete
…意味着在加载(或失败)所有< link>之前,文档的加载事件不会触发
标签:javascript,html5,hyperlink,synchronous,onload 来源: https://codeday.me/bug/20190709/1413779.html