Possible Duplicate:
Why does this Javascript code inside a non-Javascript browser have extra commenting?
Sometimes I’m seeing some Javascript which begins with <!-- and ends with //-->.
I wonder what is the use of such line? As far as I know, <!-- means comments line. But that does not seem to be the case, as the script will still work even with such line. And it also works if the line is removed.
Here is one short example:
<script language='JavaScript' type='text/javascript'>
<!--
function changelang(id) {
document.location.href='index.php&lch=1&lang=' + id }
//-->
</script>
It used to be used for old browsers which did not understand
scripttags and would render their contents nodes as text, which of course was undesirable.This may make more sense when you think of contents of
canvas,audio,noscriptelements (the latter of which is treated special today, but imagine back in the old days where the browser did not know what thenoscriptelement was).In this day and age, it is not required.
Douglas Crockford recommends against their use.
Source.