This article describes how to delay the loading of javascript code and speed up web page access.
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 notes Points:
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=”";
3. Let JS load last. Plan 2
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, it will be run in the loading order of the page from top to bottom. JavaScript code~~~ So we can put the files imported from outside the js to the bottom of the page, so that the js can 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