[英]Loading stylesheets and JavaScript taking too long
What should I do to decrease load time? 我该如何减少加载时间?
<head>
<title>NCI SwitchGears</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap-3.3.4-dist/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="bootstrap-3.3.4-dist/js/bootstrap.min.js"></script>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="menu/styles.css">
<script src="bootstrap-3.3.4-dist/js/jquery-latest.min.js" type="text/javascript"></script>
<script src="menu/script.js"></script>
</head>
Google provides a nice tool to help you speed up the loading times of your pages https://developers.google.com/speed/pagespeed/insights/ Google提供了一个很好的工具来帮助您加快页面的加载时间https://developers.google.com/speed/pagespeed/insights/
Another nice online tool can be found here 另一个不错的在线工具可以在这里找到
As a general rule: 作为基本规则:
- load 1 js files and 1 css file - compressed -加载1个js文件和1个CSS文件-压缩
- have your js at the bottom of the page, not in header -将js放在页面底部,而不是标题中
- load social tools/scripts via ajax, after page has load -页面加载后通过Ajax加载社交工具/脚本
- optimize the images/graphics you use on your template -优化您在模板上使用的图像/图形
- set proper expiration headers and caching options -设置适当的到期标头和缓存选项
More specific instructions for your pages you can find in the above tools. 您可以在上述工具中找到针对您页面的更具体说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.