When a website has a lot of js code to be loaded, the location of the js code will affect the loading speed of the web page to a certain extent. In order to make our web page load faster, this article summarizes a few points to pay attention to:
1. Lazy loading js code
< ;script type="text/javascript" src="" id="my">
In this way, js code is loaded through delay, Allow more time for web pages to load!
2. JS final loading solution 1 Insert the following code where JS needs to be inserted:
Program code
LOADING…
Of course, that LOADING... you can change it to a small picture you like. It looks very AJAX effective.
Then insert at the bottom of the page:
Program code
Your JS code is here!<script>L4EVER.innerHTML=AD_L4EVER.innerHTML;AD_L4EVER.innerHTML=”";</script>
3. Let JS load the second solution lastly This involves the loading order of the web page. For example, when introducing an external js script file, if it is placed in the head of the html, the js script will be loaded into the page before the page is loaded, and if it is placed in the body, then The javascript code will be run in the order in which the page is loaded from top to bottom~~~ So we can put the files imported from outside the js to the bottom of the page, so that the js will be introduced last, thereby speeding up the page loading speed.
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