在 Plunker 中,是否有在 Document/Window 准备好后加载 script.js 文件的设置?

In Plunker, is there a setting to load the script.js file after the Document/Window is ready?

在 Plunker 中,是否有在 Document/Window 准备好后加载 script.js 文件的设置?

如果需要,我可以使用以下设置,但是设置会很好。

只是不想将这些添加到我所有的 plunks 的顶部。

$(document).ready(function() {
   //Amazing code goes here.....
}

window.onload=function(){
   //adfsadf
}

我注意到 SO 上只有 178 个 Plunker 标记的问题,谁会把它搞砸:-)

Plunker 不会对您的标记进行任何操作以将脚本的执行推迟到文档或 window 准备就绪之后。如果您希望您的代码在文档准备好后 运行,您有两个选择:

  1. 将您的 <script src="script.js"> 标签保留在 <head> 元素中,并使用您描述的方法之一来等待文档就绪事件;或

  2. 将您的 <script src="script.js"> 移动到 <body> 标签的底部,就在 </body>.

  3. 之前

其中没有任何内容是 Plunker 特有的。这就是浏览器的工作方式。