Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

  • 0
Theo

[Solved] How to prevent Javascript code from being wrapped in CDATA?

Question

Hi

How do I prevent / turn off CDATA wrapping of JS code? 

I've tried turning off HTMLPurifier, yet my JS code is still being wrapped by CDATA.
I need to turn this off as we've encountered issues with Google Console complaining about FAQ Schema code being wrapped in CDATA. If you unwrap the schema code from CDATA, then Google is happy.
Bytw this is from a CMS page (after implementing Vekia's TinyMCE enhancements to allow for script tag to be used on CMS page)
 

<script>// <![CDATA[
console.log("hello");
// ]]></script>

 

 

Edited by Theo

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
On 10/9/2019 at 5:59 PM, datakick said:

You can use solution outlined in this stackoverflow answer

To make it work in tb, edit file /js/admin/tinymce.inc.js and paste the code snippet into default_config:

image.thumb.png.a8b6f1577f0a3432081ef5941cb87bdf.png

Thanks. Now to stop it from stripping out the type attribute <script type="javascript/text"> ...
lol

Edited by Theo

Share this post


Link to post
Share on other sites
  • 0

The original question had a second part on how to prevent TinyMCE from stripping the type attribute from the Script Tag.
I've created a post for this one specifically:

 

Edited by Theo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...