优先考虑 JavaScript 脚本:延迟不起作用
我需要优先考虑脚本,以便 jQuery、Cufon 和我的 .js 文件先于 Twitter。我尝试过 defer="defer" 以及按照我希望脚本执行的顺序将脚本放置在底部,但所有这些方法都不起作用。
我也不想修改 Twitter 的文件。有什么我可以做的吗?
I need to prioritize scripts so jQuery, Cufon, and my .js files come before Twitter does. I've tried defer="defer"
as well as placing scripts in the bottom in the order I want them to execute but all these methods aren't working.
I don't want to modify Twitter's files either. Anything I can do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
让您的脚本创建 html 以下载 Twitter 脚本。
这样它将在您的脚本之后加载并执行,该脚本位于 jQuery 和 Cufon 之后。
Have your script create the html to have the Twitter script downloaded.
That way it will be loaded and executed after your script, which comes after jQuery and Cufon.
请记住,defer 不是标准的,并且仅受 IE 支持。另外,提供更多信息。 “不工作”并不算什么。编译和执行 Javascript 的顺序是明确定义的,所以如果你做得正确,它们应该以正确的顺序执行。但是,请记住,任何块中的语法错误都会禁止整个块执行,因此请确保您认为较早运行的某些内容实际上正在运行。
Remember that defer is not standard and only supported by IE. Also, give more information. "aren't working" isn't a lot to go by. The order of compiling and executing Javascript is well define, so if you're doing things right they should execute in the right order. However, remember that a syntax error in any block will forbid the entire block from executing, so make sure something you think is running earlier is actually running at all.