简体   繁体   English

令人惊叹的减慢页面加载时间

[英]Fontawesome slowing down page load time

I have a Wordpress site with the "baskerville 2' theme installed. I've been using google page speed insights to assess my site's loading speed. It tells me that the font awesome Webfont preload request is slowing it down. I've added :我有一个安装了“baskerville 2”主题的 Wordpress 网站。我一直在使用谷歌页面速度洞察来评估我网站的加载速度。它告诉我字体真棒 Webfont 预加载请求正在减慢它的速度。我添加了:

<link rel=”preload” href=”https://dsbaudio.com/wp-content/themes/baskerville-2/fontawesome/fontawesome-webfont.woff2?v=4.3.0” as=”font” crossorigin=”anonymous”>

to the header.php and this has improved things a bit.header.php ,这使事情有所改善。

If I understand things correctly, would the site load a lot faster if the theme didn't preload web fonts at all?如果我理解正确,如果主题根本没有预加载网络字体,网站加载速度会快很多吗?

Is there a way to modify the theme (using a child theme edited offline) to revert it to standard fonts like Arial, Times or Georgia?有没有办法修改主题(使用离线编辑的子主题)以将其恢复为标准字体,如 Arial、Times 或 Georgia?

Though it is an excellent resource, it is likely that you do not need the entire FontAwesome font file.虽然它是一个很好的资源,但您可能不需要整个FontAwesome字体文件。

I often use maybe 10 of the glyphs available in that file.我经常使用该文件中可用的 10 个字形。 If you load the entire font – something like 7,000 glyphs – then you are drawing unnecessary system resources to define 6,990 glyphs that you will never use.如果你加载整个字体——比如 7,000 个字形——那么你正在绘制不必要的系统资源来定义 6,990 个你永远不会使用的字形。

The answer:答案:

Subset thy font, good programmer!子集你的字体,好程序员!

To do this, I use a font-subsetting service.为此,我使用了字体子集服务。 They tend to be free, and there are easy-to-follow instructions on their sites.他们往往是免费的,并且在他们的网站上有易于遵循的说明。 There are several, but you could try fontello: http://fontello.com有几个,但你可以试试 fontello: http ://fontello.com

I just had a look at a fairly large set of icons that I use on one of my sites, and it was 44KB.我刚刚查看了我在我的一个网站上使用的一组相当大的图标,它有 44KB。 Tiny.微小的。 Fast.快速地。

Let me know if you have any questions.如果您有任何问题,请告诉我。

You need to perform two steps process to solve this issue.您需要执行两个步骤来解决这个问题。

Step one: Go to appearance ->theme editor ->framework/dist/css/site/stacks/(yourstacks).css look for @font-face and replace with font-display:swap;第一步:去外观 -> 主题编辑器 ->framework/dist/css/site/stacks/(yourstacks).css 寻找 @font-face 并替换为 font-display:swap;

Step two: Go to appearance ->theme editor ->framework->fonts->font_awesome第二步:进入外观->主题编辑器->框架->字体->font_awesome

Insert this line of code inside the font tag font-display=“swap”;在字体标签中插入这行代码 font-display="swap";

Have you considered placing the code in your footer instead?您是否考虑过将代码放在页脚中? Some websites claim this increases load times.一些网站声称这会增加加载时间。

Alternatively, with relation to choosing default fonts, yes - either through modifying your CSS, or changing the font within your theme options.或者,关于选择默认字体,是的 - 通过修改 CSS 或更改主题选项中的字体。 You should be able to change it there... I'm not familiar with your theme sorry I could not be more specific.你应该能够在那里改变它......我不熟悉你的主题抱歉我不能更具体。

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

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