简体   繁体   English

谷歌字体外部CSS Vs在我的CSS中复制外部CSS的代码?

[英]Google fonts external CSS Vs copying the code of external css in my css?

I'm using a google font by adding a External link 我通过添加外部链接使用谷歌字体

<link href='http://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'>

This CSS only having this code 这个CSS只有这个代码

@font-face {
  font-family: 'Arvo';
  font-style: normal;
  font-weight: normal;
  src: local('Arvo'), url('http://themes.googleusercontent.com/static/fonts/arvo/v3/WJ6D195CfbTRlIs49IbkFw.woff') format('woff');
}

Can i just paste and use this code in my project css file style.css or it's necessary and better use it as a google's external css link 我可以在我的项目css文件style.css中粘贴并使用此代码,或者它是必要的并且更好地将其用作google的外部css链接

You should link it from Google, because: 您应该从Google链接它,因为:

So, it's more robust to link it from Google. 因此,从谷歌链接它更加强大。


If you want to host the font locally, read this: How to host google web fonts on my own server? 如果您想在本地托管该字体,请阅读: 如何在我自己的服务器上托管google web字体?

I imagine the only problem would be if Google decide to change the font location from 'http://themes.googleusercontent.com/static/fonts/arvo/v3/WJ6D195CfbTRlIs49IbkFw.woff' to 'http://themes.googleusercontent.com/static/fonts/arvo/v3/somethingelse.woff' . 我想唯一的问题是,如果谷歌决定改变从“http://themes.googleusercontent.com/static/fonts/arvo/v3/WJ6D195CfbTRlIs49IbkFw.woff”字体位置为“http://themes.googleusercontent.com /static/fonts/arvo/v3/somethingelse.woff'

By using their link they will likely keep that up to date. 通过使用他们的链接,他们可能会保持最新。 Basically what I am trying to say is they are less likely to change the link 'http://fonts.googleapis.com/css?family=Arvo' but are more likely to change 'http://themes.googleusercontent.com/static/fonts/arvo/v3/WJ6D195CfbTRlIs49IbkFw.woff' . 基本上我想说的是他们不太可能改变链接'http://fonts.googleapis.com/css?family=Arvo'但更有可能改变'http://themes.googleusercontent.com/ static / fonts / arvo / v3 / WJ6D195CfbTRlIs49IbkFw.woff' I'd probably stick with their external link, the only downside would be a tiny tiny tiny tiny difference in your page load time as it has to download the CSS and then the font. 我可能会坚持使用他们的外部链接,唯一的缺点是页面加载时间微小的微小差异,因为它必须下载CSS然后下载字体。 But Google has so many servers that are so fast it iwon't make a blind bit of difference. 但谷歌拥有如此之多的服务器以至于它并没有让我们有点不同。 Hope that made sense. 希望有道理。 That's my view on it as well, someone else might have another idea. 这也是我对它的看法,其他人可能有另一个想法。

I would just include it to my project css file because: 我只是将它包含在我的项目css文件中,因为:

  • you can save one http request :) 你可以保存一个http请求:)
  • full control about your css 完全控制你的CSS

If google ever changes the external css file, maybe your project goes crazy. 如果谷歌改变了外部css文件,也许你的项目会变得疯狂。 But this may depend on the Project. 但这可能取决于项目。 In most cases it does not matter if the user has the file already cached or not. 在大多数情况下,用户是否已经缓存了文件并不重要。 If you have only a small site the chance the user has this file allready chached tends to zero. 如果你只有一个小网站,那么用户拥有这个文件的机会往往是零。 Just my 2 cents… 只差我2美分......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM