保持Twitter脚本加载,直到处理完所有其他脚本

时间:2021-10-30 08:51:22

jQuery, Cufon, fonts, jQuery plugins, and JavaScript code, are at the top of a page. The Javascript code is all wrapped in a document.ready(). Two Twitter scripts, one the actual script and one the JSON, are at the beginning.

jQuery,Cufon,fonts,jQuery插件和JavaScript代码位于页面顶部。 Javascript代码全部包含在document.ready()中。两个Twitter脚本,一个是实际脚本,另一个是JSON,开头。

A problem that is going on is that I have found out that even placing the scripts at the bottom of the page, Twitter scripts delay all other scripts from running because they have been wrapped in a document.ready.

正在发生的一个问题是,我发现即使将脚本放在页面底部,Twitter脚本也会延迟所有其他脚本的运行,因为它们已经包装在document.ready中。

One solution to this I can see is taking the document.ready() off of the functions and moving them to the bottom of the page, before Twitter. Is there a better way to do this?

我可以看到的一个解决方案是在Twitter之前将document.ready()从函数中移除并移动到页面底部。有一个更好的方法吗?

2 个解决方案

#2


If execution speed is not critical, you can try setTimeout to call the Twitter script.

如果执行速度不重要,您可以尝试使用setTimeout来调用Twitter脚本。

Example:

$(document).ready(function(){

  setTimeout(callTwitterFunction, largeNumberEnoughForOtherScriptToFinishLoading)

});

#1


#2


If execution speed is not critical, you can try setTimeout to call the Twitter script.

如果执行速度不重要,您可以尝试使用setTimeout来调用Twitter脚本。

Example:

$(document).ready(function(){

  setTimeout(callTwitterFunction, largeNumberEnoughForOtherScriptToFinishLoading)

});