javascript - The page loads slowly, what are the optimization solutions?
学习ing2017-07-05 11:04:00
0
4
910
Can anyone help me find out why the page loads so slowly? I hope you can analyze it in detail and find any good solutions. Online address http://cqwind.chinacloudapp.c...
Looking at the picture, the ones that take the longest are Ajax/XHR requests.
Since static resources load very quickly, it cannot be due to network speed. So you can:
Try to merge HTTP requests on the front end.
Let the background be optimized to improve the response speed. (Looking at your situation, the most critical place should be here; if the backend is blaming you, then you can simulate HTTP requests elsewhere, such as using tools like Postman, and let the facts speak for themselves.)
1. Compress js and css, even if I look at them, they are not compressed at all
2. Compress pictures
3. You can package the css, or it is recommended to make a loading layer when loading for the first time
It is best to compress and package these resource files, which can be easily achieved with gulp. If you want to provide a better user experience, you can learn from Google earth. Load all resources and bundles on the first visit and provide a loading layer. The subsequent dynamic data must either be rotated or directly used as websocket
Also, I looked carefully and found that the call to your data is quite time-consuming, so it is recommended that you still have to do some back-end optimization. Google also has a health check tool that will provide you with suggestions
The time-consuming calculation part can be left to the background for regular processing, the results are cached, and the page can directly call the cache
Looking at the picture, the ones that take the longest are Ajax/XHR requests.
Since static resources load very quickly, it cannot be due to network speed. So you can:
Try to merge HTTP requests on the front end.
Let the background be optimized to improve the response speed. (Looking at your situation, the most critical place should be here; if the backend is blaming you, then you can simulate HTTP requests elsewhere, such as using tools like Postman, and let the facts speak for themselves.)
1. Compress js and css, even if I look at them, they are not compressed at all
2. Compress pictures
3. You can package the css, or it is recommended to make a loading layer when loading for the first time
It is best to compress and package these resource files, which can be easily achieved with gulp. If you want to provide a better user experience, you can learn from Google
earth. Load all resources and bundles on the first visit and provide a loading layer. The subsequent dynamic data must either be rotated or directly used as websocket
Also, I looked carefully and found that the call to your data is quite time-consuming, so it is recommended that you still have to do some back-end optimization. Google also has a health check tool that will provide you with suggestions
Check the client and server networks, 40 seconds is generally not normal;
Chrome -> F12 -> Audits Carefully read the suggestions he gave;
png Convert all to webP, at least use tinyPNG;
Find out the static resources that hinder loading and go to CDN;
Upgrade http/2;
Preloading / local cache;
If it is not JSP, replace Tomcat, such as nginx;
The time-consuming calculation part can be left to the background for regular processing, the results are cached, and the page can directly call the cache
Optimize calculation logic
Detection time sql