浏览器会下载一个font-face,即使它没有在页面中使用吗? [英] Will a browser download a font-face even if it is not used in the page?

查看:85
本文介绍了浏览器会下载一个font-face,即使它没有在页面中使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我可以只嵌入我可能使用的每一种字体,但是我绝对不希望对字体的额外HTTP请求不会在页面的任何地方结束,这将更容易开发。

It would be easier for development if I can just embed every typeface I'm likely to use, but I definitely don't want the extra HTTP requests for fonts that don't end up anywhere in the page. Can anyone enlighten me?

推荐答案


IE会立即下载.eot文件遇到@ font-face的声明。

IE will download the .eot file immediately when it encounters the @font-face declaration.

Gecko,Webkit和Opera都会等待,直到他们遇到与CSS规则匹配的HTML,并使用包含@ font-face字体的fontstack。 p>

Gecko, Webkit, and Opera all wait until they encounter HTML that matches a CSS rule with a fontstack including the @font-face font.

- http://paulirish.com/2009/fighting-the-font-face-fout/

因此, IE,实际上可以安全地嵌入大量的字体,只要你小心不要引用你的CSS样式中未使用的字体,因为那时它们将被浏览器下载。

So were it not for IE, it actually would be safe to embed lots of fonts, as long as you're careful not to refer to unused ones in your CSS styles, because at that point they will be downloaded by the browser.

这篇关于浏览器会下载一个font-face,即使它没有在页面中使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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