Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有人对您是否需要使用已准备好 require.js 的文档有任何想法吗?我的意思是,如果您在页面底部调用 js 并且您的 main.js 具有依赖项,那么在加载所有必要的代码之前,肯定不会执行 js 吗?
调用页面底部的js
是的,在这种情况下,您可以省略$(document).ready- 文档加载到页面结束之前。
$(document).ready
在加载所有必要的代码之前,肯定不会执行 js 吗?
不,永远不要依赖这样的时间假设。始终声明您的依赖项 - 当它们已经加载时它不会减慢您的代码,但如果它们没有加载,它将防止它失败。