This happens because HTML parser as defined by W3C is totally separated from the JavaScript parser. After the <script>
tag it looks for the closing </script>
, regardless that it’s inside comments or strings, because it treats JS code as normal text.