Andrew Harris wrote:
It is common and often recommended practice to comment javascript
placed in a document.

<script type="text/javascript" language="javascript">
   myVariable = 'woo';
   // -->

Don't bother using those comments, they're a waste of time.

The reason cited is that 'very old browsers' that do not understand
the script tag may print the raw code.

How old are we talking? Has anyone ever seen this happen? Can't we
safely leave behind what is essentially a hack?

Sadly, yes. The browser embedded in a a particular mobile phone (I think it's the Motorolla V3) does not recognise the script element and will render the script on screen if it's not commented out. However, that phone and its browser have far more significant problems and is safe to ignore.

Other than that, any browser released since the mid-90's will recognise the script element and hide its content.

While I'm on the topic - what about the whole <![CDATA[ ... ]]> thing?

No. That is for use in XHTML only. In HTML, the content of the script element is parsed differently from other markup.

See this article of mine for a more detailed explanation.

Lachlan Hunt

List Guidelines:

Reply via email to