< script />之间的区别和< script>< / script>用于在HTML中导入多个js文件

< script />之间的区别和< script>< / script>用于在HTML中导入多个js文件

问题描述:

我最近遇到的这个问题,我试图在我的HTML页面中导入多个js文件 -

This issue I recently faced, I was trying to import multiple js files in my HTML page like this -

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js" />
<script src="lib/js/backbone.js" />

但是我面对的问题是,它只加载第一个js文件,其余的js文件没有被加载。我也在浏览器中检查了网络部分,剩下的两个文件只是没有被调用。然后我改变了语法 -

But the issue I was facing is, it was loading only the first js file and the rest of the js file was not getting loaded. I also checked the network section in the browser, the remaining two file was just not getting called. Then I changed the syntax to this -

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<script src="lib/js/backbone.js"></script>

然后所有3个文件的加载成功发生。我的问题是,是

And then the loading of all the 3 files happened successfully. My question is, is

<script src="" /> 

错误的语法或者这个问题只针对我?

a wrong syntax or is this issue only specific to me?

脚本标签需要起始标签和结束标签。 来自MDN

Script tag requires both the starting and ending tag. From MDN:


标记遗漏:无,起始标记和结束标记都是必填项。

Tag omission: None, both the starting and ending tag are mandatory.