字体真棒加载速度非常慢



我一直在我的网站上做一些故障排除,因为页面加载似乎很慢。我在每个页面上都有图标,多次作为网站作为博客,并且每个博客文章都有共享图标。通过删除字体真棒,我注意到了极高的速度提升。现在我不确定该怎么做,因为我需要图标。有什么建议吗?

更新:我尝试使用我的服务器,我也使用了 CDN,但我得到了相同的结果。

把这个加载到你的脑海中:

<script type="text/javascript"> (function() { var css = document.createElement('link'); css.href = 'https://use.fontawesome.com/releases/v5.1.0/css/all.css'; css.rel = 'stylesheet'; css.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(css); })(); </script>

这到底是做什么的?好吧,它通过放置在页面头部的javascript加载字体很棒。基本上,我们在渲染页面之前渲染字体很棒,这意味着它应该加载得更快。

必须打开缓存?在 Apache 服务器上,您可以添加到您的 .htaccess 中:

 ExpiresActive On
 ExpiresByType text/css "access plus 1 month"
 ExpiresByType text/javascript "access plus 1 month"
 ExpiresByType text/html "access plus 1 month"
 ExpiresByType application/javascript "access plus 1 month"
 ExpiresByType image/gif "access plus 1 month"
 ExpiresByType image/jpeg "access plus 1 month"
 ExpiresByType image/png "access plus 1 month"
 ExpiresByType image/x-icon "access plus 1 month"

要获得有关如何加快网站速度的概述,您可以在以下位置进行测试:https://developers.google.com/speed/pagespeed/insights/

最新更新