Loading ...
Sorry, an error occurred while loading the content.

170Re: CDATA on Inline Scripts

Expand Messages
  • Douglas Crockford
    Aug 15, 2008
      --- In jslint_com@yahoogroups.com, "Paul" <DWTebriel@...> wrote:
      > I currently have code that looks like the following:
      >
      > <script type="text/javascript">
      > //<![CDATA[
      > ...
      > //]]>
      > </script>
      >
      > Since I'm doing this in xhtml, my IDE likes that tag being there,
      > otherwise it blows up on typical xml characters like [<]. However,
      > JSLint is returning a statement such as the following:

      XHTML is a fiction. If it were real, you wouldn't need to hide the
      hideous CDATA overhead behind JavaScript comments. You would do better
      to write your code like this:

      <script>
      ....
      </script>

      It is smaller, cleaner, faster.

      Even better, do not put any script in HTML files. Use script src.
      Separate the markup from the behavior. This tends to lead to better
      designs. It also can provide better performance because of
      opportunities for minification, compression, and caching.
    • Show all 4 messages in this topic