| code is as follows |
copy code |
| <!doctype HTML public-// W3C//DTD XHTML 1.0 transitional//en "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD" <meta http-equiv= "Content-type content=" text/ html charset=gb2312 "/> <title></title> <body> <div id=" demob "> </div> <div style=" Display:none id= "Demob_hidden" <!--this div put the external JS call to load--> </div <script> Function Chkdiv (divid) { var chkid=document.getelementbyid (divid); if (chkid!= null) {return true;} Else {return false;} } if (Chkdiv (' demob ')) { document.getElementById (' demob '). Innerhtml= document.getElementById (' Demob_ Hidden '). innerHTML; document.getElementById (' Demob_hidden '). innerhtml= ""; } </script> |
Where the ID for demob div is the page in the middle of the original place JS call, the following hidden ID for the Demob_hidden div and the next JS code placed in the end of the page, so that most of the contents of the Web page loaded after loading hidden div in the JS call, Then use the function of the following to assign to Demob, this can reduce the external JS loading speed to the overall load of the Web page visual impact.
Method Two
JS Delay Loading
The code is as follows:
Program code
| The code is as follows |
Copy Code |
<script language= "javascript" src= "id=" my "></script> <script> settimeout ("document.getElementById" (' my '). src= ' include/php tutorial 100.php Tutorial '; ', 3000);/delay 3 seconds </script> |
JS Final Load
Insert the following code where you want to insert JS:
Program code
| The code is as follows |
Copy Code |
| <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
| The code is as follows |
Copy Code |
<span Class=spanclass id=ad_l4ever> Your JS code is here!</span>. <script>l4ever.innerhtml=ad_l4ever.innerhtml;ad_l4ever.innerhtml= "";</script> </body>
|