Is it possible to open and close a script tag inside another script tag?
Example
<script type="..." src="...">
code here
<script type="!!!" src="!!!">
code also here
</script>
</script>
Is it possible to open and close a script tag inside another script tag?
<script type="..." src="...">
code here
<script type="!!!" src="!!!">
code also here
</script>
</script>
If you put a <script> tag between a <script> and </script>, that script then will be treated as a JavaScript expression.
In most cases, that means it generates an error message like ...
Uncaught SyntaxError: Unexpected token <
... or ...
SyntaxError: expected expression, got '<'
However, it doesn't generate an error per se. For example, consider the following code :
console.log('BEFORE');
var script = 0; var bool = 1 <script> 2;
console.log(bool);
console.log('AFTER');
This doesn't produce a code, because 1 <script> 2 is evaluated as this :
1is smaller thanscriptis greater than2Because script exists as a variable, that doesn't produce any error. In the code here-above, console.log(bool); outputs false.