Rito
Rito

Reputation: 3298

Difference between <script /> and <script></script> for importing multiple js file in HTML

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" />

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>

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?

Upvotes: 1

Views: 280

Answers (1)

Nisarg Shah
Nisarg Shah

Reputation: 14561

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

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

Upvotes: 8

Related Questions