This article describes how to delay the loading of JavaScript code and speed up access to your Web pages.
When a site has a lot of JS code to load, JS code placed in a certain degree will image the loading speed of the Web page, in order to let our web page loading faster, this article summed up a few points of attention:
1. Delay Loading JS Code
Copy Code code as follows:
<script type= "Text/javascript" src= "id=" my "></script>
<script type= "Text/javascript" >
SetTimeout ("document.getElementById (' my '). src= ' include/php100.php ';", 3000);/delay 3 seconds
</script>
This way by delaying loading JS code, to allow more time to load the page!
2, JS final load scheme a
Insert the following code where you want to insert JS:
Program code
Copy Code code as follows:
<span id= "L4ever" >LOADING...</span>
Of course, that loading ... You can switch to your favorite small picture. It looks like an Ajax effect.
Then insert at the bottom of the page:
Program code
Copy Code code as follows:
<span id= "Ad_l4ever" > Your JS code is here!</span >
<script>L4EVER.innerHTML=AD_L4EVER.innerHTML; Ad_l4ever.innerhtml= "";</script>
3, let JS final load scheme two
This involves the loading sequence of the page, such as the introduction of external JS script file, if placed in the head of the HTML, the page before loading the JS script will be loaded into the page, and into the body, will be in accordance with the page down from the loading sequence to run JavaScript code ~ ~ ~ So we can put JS outside the introduction of the file to the bottom of the page, to let JS finally introduced, thus speeding up the page load speed.