<分区>
我想知道是否有关于我应该在何处(在什么地方)包含网络字体的最佳实践。我的意思是使用 <link href...>
.看起来我看到的每个网站的 head 标签之间都包含网络字体,但我看到人们这样做的唯一原因是首先下载字体,所以当默认字体更改为下载的。
Web 字体应该/不应该放在 head 标签之间还有其他原因吗?
最佳答案
这是引自Optimize the order of styles and scripts (来自谷歌的 "Make the Web Faster" Best Practices docs )
stylesheets should always be specified in the head of a document for better performance, it's important, where possible, that any external JS files that must be included in the head (such as those that write to the document) follow the stylesheets, to prevent delays in download time.
现代浏览器会等待任何类型的渲染,直到整个 <head>
部分被检索(包括其中链接的文件)。所以最好添加
尽可能少地处理此部分。
所以你最好在任何 <script>
之前添加它在<head>
文档的一部分。
还有更多的考虑,Yahoo's list of optimizations非常值得您花时间通读。 Google has some good advice
关于html - 网页字体应该包含在 head 标签之间吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35214552/