|
|
|
|
|
by niyazpk
5165 days ago
|
|
We do something like this: $(function(){
setTimeout(function(){
/* load twitter, facebook */
}, 2000);
});
This tries to make sure that all the essential work to be done on the page is completed before the less important Twitter, FB buttons are loaded. |
|
$(function(){}); is shortcut for $(document).ready(); which waits until all other external content has been loaded. [1]
If for some reason you are loading something else you need after .ready() fires, and you can't load that inside of a single .ready() call for some reason, you can potentially add multiple callbacks to .ready() (they will be executed in order [2]), or attach a .load() to that particular item instead (maybe even inside your .ready().)
Timeout hacks are not a performance improvement.
[1] http://api.jquery.com/ready/ [2] http://stackoverflow.com/questions/5263385/jquery-multiple-d...