The important thing is that at the present time, regardless of whether a particular browser supports JavaScript or not, it does not matter (it is obvious that the vast majority do this) - it does not matter, because almost everyone understands script blocks, which means that they know that they ignore JavaScript even if they cannot interpret it.
Matt Cruze gives a slightly more detailed explanation on his JavaScript Toolbox site why not to use HTML comments in script blocks.
Quote from this page:
Do Not Use HTML Comments In Script Blocks
In the ancient days of javascript (1995), some browsers, such as Netscape 1.0, did not have support or knowledge of the script tag. Therefore, when javascript was first released, it took a technique to hide the code from older browsers so that they did not display it as text on the page. "Hack" had to use HTML comments in a script block to hide the code.
Using HTML comments in a script
// DON'T do this! Code is just representative on how things were done <script language="javascript"> </script>
Today there are no widespread browsers that do not know about <script>, so hiding the javascript source is no longer required. In fact, this can be considered harmful for the following reasons:
- In XHTML documents, the source will actually be hidden from all browsers and will be useless
- - not allowed in HTML comments, so any reduction operations in the script are invalid
Noldorin Apr 30 '09 at 20:23 2009-04-30 20:23
source share