0

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>
1
  • I don't know. Let us know if it worked once you've tried. Commented Aug 6, 2014 at 6:26

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.