Reputation: 47
I mean, if I use JavaScript in an external file(write script code in another file, not in HTML file).
I write this code in my HTML file <script src="filename.js"></script>
But this code works only if I left the tags empty.
So I'm wondering that if we use JavaScript in an external way, should I leave the tag empty as I mentioned?
Upvotes: 1
Views: 180
Reputation: 1629
Yes.
It's important to note that a script
element using the src
attribute should not include additional Javascript code between the <script>
and </script>
tags. If both are provided, the script file is downloaded and executed while the inline code is ignored.
Note that html5 allows comments inside an external script tag. Reference html5
Upvotes: 1