性能优化

性能优化

脚本位置

因为脚本阻塞其他页面资源的下载过程,所以推荐的办法是:将所有<script>标签放在尽可能接近<body>标签底部的位置,尽量减少对整个页面下载的影响。例如:

<html> 
 <head> 
 <title>Script Example</title> 
 <link rel="stylesheet" type="text/css" href="styles.css"> 
 </head> 
 <body> 
 <p>Hello world!</p> 
 <-- Example of recommended script positioning --> 
 <script type="text/javascript" src="file1.js"></script> 
 <script type="text/javascript" src="file2.js"></script> 
 <script type="text/javascript" src="file3.js"></script>
 </body> 
</html>

脚本数量

  • 尽可能的少
posted @ 2023-06-09 11:37  风紧·扯呼  阅读(4)  评论(0)    收藏  举报