Is there a difference between --
<![CDATA[
// content of your Javascript goes here
]]>
- Adding it as part of html response from server v/s
- Adding it dynamically after page load using a javascript (lets say $('body').append(/CDATA_goes_here/))
Main question here is whether CDATA needs to be available as part of page source or not?
Leaving aside the general issues with adding content using JS, CDATA doesn't make any difference.
It renders in an XHTML document and gets parsed as a comment in an HTML document.