Is it possible to reduce Google Web Fonts to one request if I'm using multiple fonts?

佐手、 提交于 2019-12-19 19:16:22

问题


I ran a speed test on my website and one of the suggestions was to reduce my external requests. I am using 3 Google Web Fonts, in effect 3 separate requests. Is it posible to combine these into 1 request?


回答1:


You can combine several fonts with just one call using the | character. Example:

<link href='//fonts.googleapis.com/css?family=Cantarell|Terminal+Dosis' rel='stylesheet' type='text/css'>



回答2:


Aren't Fonts (like image assets, JSON objects, or videos) separate resources that need individual requests?




回答3:


You can avoid the three requests by embedding the fonts in data: URIs inside the CSS - at least in IE9+ and most modern browsers.

note: they also work in IE8, but are limited to 32KB

note2: obviously, you won't get the benefits of the Google CDN, since you'll have to serve the fonts inside your CSS...




回答4:


Yes you can load multiple fonts in single request like

<link rel='stylesheet' type='text/css' href='https://fonts.googleapis.com/css?family=Montserrat:400,700|Lato:300,400,700,900'>


来源:https://stackoverflow.com/questions/8566947/is-it-possible-to-reduce-google-web-fonts-to-one-request-if-im-using-multiple-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!