I have a very basic html file that uses a script tag to import a javascript file, but the javascript file is not run when I load the html locally in a browser. How am I formatting the script tag incorrectly?
Folder Structure
-folder --test.html --script.js
test.html
<html lang="en"> <head> <meta charset="utf-8"> <title>TEST</title> </head> <body> <p>TEST</p> <script type='text/javascript' src="script.js" /> </body> </html>
script.js
console.log('HELLO WORLD') (function () { setTimeout(() => alert('HELLO WORLD'), 3000) })();
You should close your script tag in a separate tag :
<script type="text/javascript" src="script.js"></script>
2.1m questions
2.1m answers
60 comments
56.8k users