Can I have something like this?
<script src="path-not-found.js">
//if file path is incorrect, then do scripting here
//for eg.
console.log('path not found');
</script>
Can I have something like this?
<script src="path-not-found.js">
//if file path is incorrect, then do scripting here
//for eg.
console.log('path not found');
</script>
No. You can't.
If the src attribute is available then script's contents are ignored.
That means, even if the src path is incorrect it will ignore it's contents because it just checks for src attribute and if it is there, the contents inside script tag would be ignored.
You need to use two separate <script> tag and do coding there:
first one with src for external file, and the second one without src, but with the code, which will be executed after that file.