Pagespeed removes //<![CDATA[ from Javascript

200 views
Skip to first unread message

Marc Mayr

unread,
Apr 14, 2015, 7:45:54 AM4/14/15
to ngx-pagesp...@googlegroups.com
Hey,
The rewrite_javascript is removing the  //<![CDATA[ from my javascripts.

For example from:

<script type="text/javascript">
//<![CDATA[
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'XXXX', 'auto');
ga('require', 'ec');
//console.log('ec enabled');
ga('require', 'displayfeatures');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
//]]>
</script>





 
I already tried to 
pagespeed  RetainComment "<![CDATA[*";

but without any success..
Any suggestions?

Kind Regards,
Marc

Jeff Kaufman

unread,
Apr 14, 2015, 7:50:11 AM4/14/15
to ngx-pagesp...@googlegroups.com
Typically you include  //<![CDATA[ ... //]]> in scripts that might be served out as xhtml.  PageSpeed removes this CDATA block if it can see the page is not xhtml, saving bytes.

Is this causing a problem?


--
You received this message because you are subscribed to the Google Groups "ngx-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.
Visit this group at http://groups.google.com/group/ngx-pagespeed-discuss.
For more options, visit https://groups.google.com/d/optout.

Marc Mayr

unread,
Apr 14, 2015, 8:25:51 AM4/14/15
to ngx-pagesp...@googlegroups.com
Well when I had the old remarketing Tag installed the google tag manager said that CDATA is missing.
But with the google universal analytics it seems to work fine without CDATA.
So isn't CDATA required?

Jeff Kaufman

unread,
Apr 14, 2015, 8:44:41 AM4/14/15
to ngx-pagesp...@googlegroups.com
CDATA should only be required if you're serving XHTML, which it sounds like you're not.  So it sounds like this is actually all set!

--
Reply all
Reply to author
Forward
0 new messages