<script type="text/javascript">
//<![CDATA[
Some code...
//]]>
</script>
We agree that magento use the CDATA in javascript
pieces codes, but I would like to know which is really the utility of this. There are some who say that we should put it in the XHTML and XML. So for exemple in some phtml, if i need to add a javascript function to validate some field or add a class etc … i should add the CDATA between the code or not necessarily.
Best Answer
I found also this answer:
It to ensure that XHTML validation works correctly when you have JavaScript embedded in your page, rather than externally referenced.
XHTML requires that your page strictly conform to XML markup requirements. Since JavaScript may contain characters with special meaning, you must wrap it in CDATA to ensure that validation does not flag it as malformed.