Forum Moderators: open

Message Too Old, No Replies

how important to <!-- hide --> ?

         

PsychoTekk

4:40 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



how important is it to hide e.g.
<style type="text/css">
<!--
...
-->
</style>
would older browsers show the stylelines as text?

creative craig

4:56 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good question I never hide any scripts I use.

BlobFisk

5:48 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I very rarely do it any more either. Traditionally it was used in order to hide the script from browsers who couldn't parse the script. The browser would ignore the <script..> or <style..> but may have tried to render the script itself, so developers hid it from them within comment tags.

These days there are very few browsers that don't understand the major client-side scripting languages and so it's not really that important, IMHO.

The one majoy exception to the above may be screen readers, although if memory serves me, I believe that they are intellegent enough to run the script or ignore it.

[edited by: BlobFisk at 5:55 pm (utc) on July 15, 2002]

txbakers

5:48 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think it's that important anymore. When Javascript first came out, version 1 and 2 browsers would crash if they saw the scripting, so it was common to comment it out.

Today's browsers just ignore it without crashing.

gsx

6:31 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



It is important for very old browsers to hide but not for modern browsers.

But if you are going to hide then the closing comment must be commented out of the JavaScript (or whatever code type it is).

In JavaScript:

-->

should be changed to:

//-->

This gets JavaScript to ignore it. It is automatically ignored in most modern browsers anyway, but Netscape 4 and some others cause a JavaScript error because it thinks that '-->' is a command and tries to run it!

gsx

6:33 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



...and with style being a more modern command, you should really comment them out if you are using inline styles but you are better using an external file (if possible) for a stylesheet.

PsychoTekk

6:46 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



hmmm... i just edited 785 files (automated)
and generated diff files for each subdirectory
(not automated since my batch files don't seem to work with cygwin
and i don't think there is a flag to tell cygwin to include
all subdirectories when using the diff function)
now they all contain
<STYLE type="text/css"><!--BODY{font-family:verdana,sans-serif}--></STYLE>

is this a problem for those old browsers?

rewboss

9:36 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



I think some people are talking cross-purposes here: the original question was whether or not it is necessary to comment out CSS, not JavaScript.

I suppose if you're still getting a large number of hits from second-generation browsers, you might need to.

Is anyone still getting hits from second-generation browsers?

creative craig

10:04 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My site has been up since August of last year and I havent had a hit from anything earlier than IE 5.

BlobFisk

11:24 am on Jul 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




Is anyone still getting hits from second-generation browsers?

I haven't seen a hit from a second generation browser in about 18 months...

tedster

1:06 pm on Jul 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I guess it depends on the territory - I see a few Netscape 2 hits on several client sites every month. They come from libraries and .edu's, as well as a few long-time engineers who are outside IT disciplines.

I don't develop pages that support these folks (thank goodness!) but I do comment out my styles and scripts.

creative craig

8:14 am on Jul 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since me opening my big mouth saying that I only get hits from IE in the past week or so i have had:

23 hits from Netscape 5.x
7 hits from Netscape 4.x
13 hits from Netscape 3.x

and a couple from Lynx and Opera...

strangely enough the hits came the same day as I joined this thread... so who was it anyone gonna own up to it ;)

Having said that my stats page looks better for it, not all MSIE now. :)