I ran my site through the W3C validator, and a bunch of errors were caused by the Google Website Optimizer javascript.

It seems weird that would happen. If I put CDATA around it, the error go away. I assume that the code will still work?

So, I'm wondering if there's ever a time it's bad to put CDATA around javascript? and Why would Google's javascript snippets not validate in the first place?


It probably has to do with the doctype. I suspect you're using XHTML. JavaScript Contains Characters Which Can Not Exist in XHTML. Raw < and & characters are not allowed except inside of CDATA Sections. See this page for more.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.