HighDots Forums  

Should we continue to hide script or not ?

Javascript JavaScript language (comp.lang.javascript)


Discuss Should we continue to hide script or not ? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Asterbing
 
Posts: n/a

Default Should we continue to hide script or not ? - 06-27-2007 , 06:59 AM






Should we continue to hide the inline script content or not ?

I mean using this well known syntax :

<script type="text/javascript"><!--
document.write("test");
//--></script>

rather than this one :

<script type="text/javascript">
document.write("test");
</script>

Kowing a <noscript> tag exists somewhere in the page.

What's your opinion ?


Reply With Quote
  #2  
Old   
rf
 
Posts: n/a

Default Re: Should we continue to hide script or not ? - 06-27-2007 , 07:08 AM







"Asterbing" <no (AT) thanks (DOT) com> wrote

Quote:
Should we continue to hide the inline script content or not ?

I mean using this well known syntax :

script type="text/javascript"><!--
document.write("test");
//--></script
A few minutes browsing *any* web related newsgroup would have given you the
answer.

There is no need to "hide" script using HTML comments, and there has not
been any need to since Netscape 2. We are now in the next century

--
Richard.




Reply With Quote
  #3  
Old   
Asterbing
 
Posts: n/a

Default Re: Should we continue to hide script or not ? - 06-27-2007 , 07:38 AM



In article <46824617$0$46400$c30e37c6 (AT) pit-reader (DOT) telstra.net>,
rf (AT) invalid (DOT) com says...
Quote:
There is no need to "hide" script using HTML comments, and there has not
been any need to since Netscape 2. We are now in the next century

Right, thanks


Reply With Quote
  #4  
Old   
shimmyshack
 
Posts: n/a

Default Re: Should we continue to hide script or not ? - 06-27-2007 , 08:07 AM



On Jun 27, 12:38 pm, Asterbing <n... (AT) thanks (DOT) com> wrote:
Quote:
In article <46824617$0$46400$c30e3... (AT) pit-reader (DOT) telstra.net>,
r... (AT) invalid (DOT) com says...

There is no need to "hide" script using HTML comments, and there has not
been any need to since Netscape 2. We are now in the next century

Right, thanks
having said that though there is the related topic of how to present
inline javascript in xhtml, so that xml parsers don't trip up on it,
its another subject but amounts to using the following syntax:

<script type="text/javascript">
//<![CDATA[

//]]>
</script>

you will thus not get warnings when validating your strict xhtml doc,
when you use < and other characters the parser might otherwise trip up
on.



Reply With Quote
  #5  
Old   
Richard Cornford
 
Posts: n/a

Default Re: Should we continue to hide script or not ? - 07-02-2007 , 02:11 PM



shimmyshack wrote:
Quote:
On Jun 27, 12:38 pm, Asterbing wrote:
r... (AT) invalid (DOT) com says...

There is no need to "hide" script using HTML comments, and there
has not been any need to since Netscape 2. We are now in the next
century

Right, thanks

having said that though there is the related topic of how to present
inline javascript in xhtml, so that xml parsers don't trip up on it,
No such issue exists. First there is almost no commercial use of (real)
XHTML because IE browsers do not support it at all. Second, inline
script element content in XHTML is unambiguously PCDATA and so the rules
for how it will be handled by an XML parser are certain, and so you know
that inline scripts need to be entified so that mark-up significant
characters can be properly handled. And third, given 2 most people would
recommend only using imported scripts with XMTML.

Quote:
its another subject but amounts to using the following syntax:

script type="text/javascript"
//<![CDATA[

//]]
/script
If this was (real) XHTML then the javascript 'end of line' comment
sequences would be redundant. The fact that they are here betrays the
fact that this has nothing to do with XHTML at all but is actually about
how to allow an inline script in a tag-soup HTML file that is attempting
to give the illusion of bang XHTML non-problematic in the event of the
mark-up being exposed to an XML or XHTML validator. As validating
mark-up which is not expected to ever be interpreted as XMTML with an
XHTML validator a pointless and irrational activity there is little
point in conjuring up any "hide script" incantation for that context.

In addition, while the occurrences of XML mark-up significant characters
in scripts is high, wrapping any old arbitrary block of script code in
<!CDATA[ ... ]]> mark-up does not fully address the issue in a real
XHTML context as ']]>' is a valid construct in javascript (i.e.
something like - if(a[b[c]]>2){ ... } -)

Quote:
you will thus not get warnings when validating your strict
xhtml doc,
Strict or transitional XHTML is an irrelevance. You may still get
warnings if the script includes the sequence ']]>' in its source code,
and the 'end of line' comments are not necessary (or event relevant) to
getting the mark-up to validate.

Quote:
when you use < and other characters the parser might otherwise
trip up on.
What you are describing here is how to stop the CDATA contents of script
elements in documents that are really (tag soup) HTML interfering with
the illusion that those documents are XHTML in a way that will not cause
issues when those documents are interpreted as (tag-soup) HTML by the
receiving browser. But as the real consequences of applying the illusion
of XHTML to documents that are really HTML is mostly to spread confusion
as to the real nature of those documents the whole practice is
irrational, counter-productive, folly.

Richard.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.