关于为什么网站缓慢/如何加快速度的建议? [英] Suggestions on why site is slow/how to speed up?

查看:35
本文介绍了关于为什么网站缓慢/如何加快速度的建议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道该网站非常基于图像,我尽可能限制插件并压缩 CSS 和样式.它不应该像现在这样慢.任何原因或我可以做些什么来加快速度?谢谢

I know the website is very image based, I have limited plugins as much as I can and compressed CSS and styling. It shouldn't be as slow as it is. Any reason why this or what I can do to speed it up? Thanks

推荐答案

在我看来

1- 你使用了太多的 css 和 javascript
2- 在首屏内容中消除阻止渲染的 JavaScript 和 CSS
3- 你应该优化你的形象
4-您可以将服务器升级到更快的服务器
5- 启用压缩和浏览器缓存
还有……

1- you are using too much css and javascript
2- Eliminate render-blocking JavaScript and CSS in above-the-fold content
3- you should optimize your image
4- you can upgrade your server to faster server
5- Enable compression and browser caching
and .....

如何改进以上步骤:

1- 为了获得更好的性能,最好将页面大小保持在 600kbit 以下,通常是因为主题或我们使用的插件,如果可以,请将模板更改为优化版本并减少不必要的插件.另一方面,有一些功能可以通过少量代码处理,但我们宁愿安装一个新插件,这样新插件就有自己的 javascript 和 css

2-将所有 javascript 代码放在 </body> (help),并为您的 css 创建一个 javascript 加载器,将您的 css 插入到头部.(help) 渲染阻塞的简单示例

how improve above steps:

1- for better performance its better to keep page size under 600kbit usually it's because of theme or the plugin we use, then if you can, change your template to an optimize version and reduce your unnecessary plugins. on the other hand there are some features that can handle by just few codes, but we rather to install a new plugin so new plugins has its self javascript and css

2-put all your javascript codes on the footer befoter </body> (help), and create a javascript loader for your css, that insert your css on the head.(help) simple example of render-blocking

<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
    <!-- do not insert css or javascript here -->
</head>
<body>
<!--
 #################
    contents
#################
 -->
<script type="text/javascript" src="/dis/cssloader.js"></script>
<script type="text/javascript" src="/dis/scripts.js"></script>
</body>
</html>

和你的 cssloader

and your cssloader

//cssloader.js
var version = "?v1";
var cb = function() {
    var styles = [
        "/dist/custom1.min.css",
        "/dist/custom1.min.css",
    ];
    var h = document.getElementsByTagName('head')[0];
    for (var i = 0; i < styles.length; i++) {
        var l = document.createElement('link');
        l.rel = 'stylesheet';
        l.href = styles[i]+version;
        h.appendChild(l);
    }
};
var raf = requestAnimationFrame || mozRequestAnimationFrame || webkitRequestAnimationFrame || msRequestAnimationFrame;
if (raf) raf(cb);
else window.addEventListener('load', cb);



3- 优化图像意味着尽可能缩小图像比例,并将图像保存到网络上(如果您使用的是 photoshop,它可以选择执行此操作,很明显它会降低图像质量)

4-有时只是服务器上的一些配置,提高其性能5- 如果您使用的是 apache,则应该在 apache 配置中添加一些代码行,以便为它启用压缩和缓存,您也可以通过 .htaccess 执行此操作(help)(帮助)

这篇关于关于为什么网站缓慢/如何加快速度的建议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆