Home >Web Front-end >JS Tutorial >Why Can\'t Inline JavaScript Be Included in External Script Tags?
Why Can't You Execute JavaScript in External Script Tags?
When using tags, external JavaScript files are loaded and executed. However, attempting to include JavaScript code within such tags, like:
<script src="myFile.js"> alert( "This is a test" ); </script>
will fail without errors. This is because a script element can only load one script at a time, either from a URL or inline. Including both results in the inline script being ignored.
To execute JavaScript within a page, you need to create multiple