Remove CDATA script from the page source

On my site i am getting some unnecessary CDATA script on the page source.

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


I want to remove it. I am unable to find the exact source form where it is come. Please suggest me with a solution.

• You want to remove cdata only, as Clive appears to think, or the whole script, as AyeshK apparently assumed in his answer? Please clarify. – Mołot Jun 19 '13 at 12:22

I'm assuming you're using an HTML5 DOCTYPE, The CDATA tags are required for XML-based documents (including XHTML).

The characters look to be hard-coded into common.inc, line 4287:

$embed_prefix = "\n<!--//--><![CDATA[//><!--\n";$embed_suffix = "\n//--><!]]>\n";


Examining that code I think the only way to intercept it would be to override theme_html_tag() in your theme, e.g.

function MYTHEME_html_tag($vars) { if ($vars['element']['#tag'] == 'script') {
unset($vars['element']['#value_prefix']; unset($vars['element']['#value_suffix'];
}

return theme_html_tag($vars); }  For Drupal 7, where every theme function has preprocess functions, you could use the following code. function mytheme_preprocess_html_tag(&$variables) {
if ($variables['element']['#tag'] == 'script') { if (strpos($variables['element']['#value'], "\n<!--//--><![CDATA[//><!--\n") !== FALSE) {
$variables['element']['#value_prefix'] = str_replace("\n<!--//--><![CDATA[//><!--\n", "",$variables['element']['#value_prefix']);
}
if (strpos($variables['element']['#value'], "\n//--><!]]>\n") !== FALSE) {$variables['element']['#value_suffix'] = str_replace("\n//--><!]]>\n", "", $variables['element']['#value_suffix']); } } }  I remove the prefix and suffix only when they are present; I also remove only the part we don't want, not the full prefix/suffix. Not sure this is what you were asking (remove the CDATA tags), but I came across this post in my search of wanting to remove the CDATA tags for one inline JS script, and Clive's answer got me headed in the right direction. But I ultimately used... function MYTHEME_preprocess_html_tag(&$vars) {
if (strpos($vars['element']['#value'],$needle) !== FALSE) {
unset($vars['element']['#value_prefix']); unset($vars['element']['#value_suffix']);
}
}


Just to give another example if anyone comes across the same scenario.

Set the field as: Text format "PHP" then put your css clases inside the tag style

• You should explain how this is going to help the OP. – kiamlaluno Jul 17 '14 at 21:05