开发者

Delay external javascript load by seconds

开发者 https://www.devze.com 2023-01-06 02:03 出处:网络
I have ONE external JavaScript file containing jQuery, Cufon, fonts, and the replace functions. I need this file to be loaded twice once on page load and again 3 seconds after page load. Is this possi

I have ONE external JavaScript file containing jQuery, Cufon, fonts, and the replace functions. I need this file to be loaded twice once on page load and again 3 seconds after page load. Is this possib开发者_JAVA技巧le?


Don't load it twice. Wrap what you have in it into a function, then call the function once when it loads, and once more after three seconds. For example, you might have something like this in your JavaScript file:

doSomeProcessing();
doSomeMoreProcessing();

Change it like this:

function myJavaScriptFile() {
  doSomeProcessing();
  doSomeMoreProcessing();
}
setTimeout(myJavaScriptFile, 3000);
myJavaScriptFile();


I don't think you need to load it twice. How about the following?

setTimeout(function(){Cufon.refresh();},3000);

disclaimer: I know nothing about Cufon and gleaned my knowlege from here


setTimeout(jQuery.getScript( url, [ success(data, textStatus) ] )),3000);

http://api.jquery.com/jQuery.getScript/

0

精彩评论

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