我一直在我的网站上做一些故障排除,因为页面加载似乎非常慢。我在每个页面上都有图标,多次作为网站作为博客,每个博客帖子都有共享图标。通过删除字体棒,我注意到了一个极大的速度提升。现在我不知道该怎么做,因为我需要这些图标。有什么建议吗?
更新:我尝试使用我的服务器,我也使用了CDN,但我得到了相同的结果。
发布于 2016-03-09 08:27:56
把这个加载到你的大脑中:
<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来加载字体。基本上,我们是在渲染页面之前渲染字体,这意味着它应该加载得更快。
发布于 2016-03-09 05:12:28
必须打开缓存吗?在Apache Server上,您可以将以下内容添加到.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/
https://stackoverflow.com/questions/35877994
复制相似问题