I've been hunting for the reason we don't do the comment
trick to hide javascript.
Did you find any justification for using it that has had any validity in
the last half decade? Sometime you don't do something became there is no
reason for ding it, rather than that you cannot find a reason for not
ding it.
I can't remember which browser needed this.
Browsers pre-dating and contemporary with Netscape 2 would have no idea
what a SCRIPT element was and so would tend to treat their contents as
text to be displayed. Browsers produced after that time would have no
problem knowing to ignore SCRIPT elements even if they could not handle
scripts themselves.
I think it was a very old browser.
Currently version 4 era browsers are considered very old (if not
dinosaurs), and even the preceding generation did not need 'script
hiding'.
<script type="text/javascript">
<!--
alert("hi");
-->
Since that the content of an HTML script element is script source code
the <!-- character sequence cannot be interpreted as mark-up in that
context. To enable script hiding to work at all (that is, not to cause
syntax errors in browsers that understand scripts) the <!-- sequences is
treated as an alternative opening single line comment token (alternative
to //). This is not true of the -->, which could not be treated
specially as it is a valid sequence of javascript operators ( x-->y -
would be a 'is x greater than y' expression with post-decrement of x).
The 'script hiding' tended to get around that by hiding the --> sequence
in a javascript single line comment. I.E. writing //--> instead of
just -->. Error correction in IE (and probably some other browsers) will
let you get away with just --> in some contexts, but your formulation
above will certainly result in script syntax errors in some browsers.
Richard.