Home >Web Front-end >JS Tutorial >How to improve javascript loading speed

How to improve javascript loading speed

高洛峰
高洛峰Original
2017-01-04 10:45:081703browse

The method is as follows:

1. Place all <script> tags as close to the bottom of the <body> tag as possible to ensure that the page is parsed before the script is run and to minimize downloading of the entire page. Impact</script>

2. Limiting the total number of <script> on the page can also improve performance. Whenever page parsing encounters a <script> tag, a period of time follows for code execution. Minimizing these latency times can improve the overall performance of your page. </script>

3. Reduce the number of external script files referenced. Each HTTP request incurs an additional performance burden, and downloading one 100KB file is faster than downloading four 25KB files. In summary, reduce the number of external script files you reference.

4. Download the script in a non-blocking way. After the page has finished loading, load the JavaScript source code

The above is the entire content of this article. I hope that the content of this article can be of some help to everyone's study or work. I also hope to support the PHP Chinese website!

For more articles on how to improve javascript loading speed, please pay attention to the PHP Chinese website!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn