Does anyone still use the old
<!-- hide JS from old browsers -->
trick?
As I recall, this was targeted at people who used Netscape, or IE4.
I just checked out our stats and in the last month we had more people visit the site using "Playstation Portable " (4 visits) as their user agent than we had using Netscape (1 visit).
Is there any point in me even having the "hide" thing in my javascript?
Does anyone still use the old
<!-- hide JS from old browsers -->
trick?
As I recall, this was targeted at people who used Netscape, or IE4.
I just checked out our stats and in the last month we had more people visit the site using "Playstation Portable " (4 visits) as their user agent than we had using Netscape (1 visit).
Is there any point in me even having the "hide" thing in my javascript?
Share Improve this question asked Apr 20, 2011 at 4:35 nedludnedlud 1,8324 gold badges19 silver badges33 bronze badges4 Answers
Reset to default 13No, you no longer need to do that.
Crockford also says...
Do not use the
<!-- //-->
hack with scripts. It was intended to prevent scripts from showing up as text on the first generation browsers Netscape 1 and Mosaic. It has not been necessary for many years.<!-- //-->
is supposed to signal an HTML ment. Comments should be ignored, not piled and executed. Also, HTML ments are not to include--
, so a script that decrements has an HTML error.
No. {insert extra chars here to meet limit for SO}
The way I figure it, if you're designing an application with which one of the main selling points is javascript-based interactivity, there's no point in catering to older browsers.
Still, it's important to know the specific goals of your product. You need to know who you're targeting and make an informed decision as to whether or not it's worth it.
In any case, you should make an attempt to discover whether or not a browser has javascript enabled, and if not, inform them of why your site will not work.
Yes, and you should, too. Drupal does it this way:
<script type="text/javascript">
<!--//--><![CDATA[//><!--
...
//--><!]]>
</script>