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';
   // -->
</script>

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.

http://lachy.id.au/log/2005/05/script-comments

--
Lachlan Hunt
http://lachy.id.au/


*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************

Reply via email to