开发者

How to load a page quickly that contains slow-loading social network content?

Right now I have a with social media icons and they take for ever to load,the code for these buttons is near the top of the code so it is slowing everything else down i think.

Isnt there a way to have where i want the buttons to go but put the codes to the buttons right 开发者_运维技巧before

so the class x is just a place holder and the button code right before will fill that space AFTER the rest of the page loads?


You can use the document onReady event to run Javascript code when all the rest is done loading. In jQuery, $(document).ready(funct) will do the trick.


<script type="text/javascript" src="jquery"></script>
<script type="text/javascript">
$(document).ready(function(){
     //for example you can do this :
    document.write("<script type='text/javascript' src='something.js'></script>")
});
<script><br/>

this will loads you scripts in body after other elemnts loaded but if this solves your problem you should do write your script in some other element to ignore infinite loop of $(document).ready() like this perhaps :
document.getElementById('myDiv').innerHTML="";

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜