Title: HTML Minify -&gt; CDATA Issue
Last modified: November 15, 2019

---

# HTML Minify -> CDATA Issue

 *  Resolved [disturbed-pixel](https://wordpress.org/support/users/disturbed-pixel/)
 * (@disturbed-pixel)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/html-minify-cdata-issue/)
 * Hi,
 * Before posting i have tried to dig deeper, but it seems that every time i enable
   HTML minification i get the following errors (over 30) in the Chrome console:
 * Uncaught SyntaxError: Unexpected token ‘<‘
 * It’s related to every CDATA instance that the W3TC plugin wraps around any block
   of of inline Javascript. I have tried changing my document type to XHTML and 
   XML encoding:
 * — php
 *     ```
       header("Content-type: application/xhtml+xml"); 
       echo '<?xml version="1.0" encoding="UTF-8"?>';
       ```
   
 * — html
 *     ```
       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
       ```
   
 * Which prevents this error occurring, but then it gives me many more issues minifying
   anything after an ampersand for example “&raquo”. Being that it’s strict.
 * I’m using HTML5 doctype declarations
    `<!DOCTYPE html>` How can i minify the 
   HTML without the CDATA issue?
 * I’ve seen posts talking about adding // before each CDATA block.
 *     ```
       <script>
       //<![CDATA[
           // insert code
       //]]>
       </script>
       ```
   
 * Can we add this automatically?
 * Please advise
    Thanks
    -  This topic was modified 6 years, 6 months ago by [disturbed-pixel](https://wordpress.org/support/users/disturbed-pixel/).
    -  This topic was modified 6 years, 6 months ago by [disturbed-pixel](https://wordpress.org/support/users/disturbed-pixel/).
      Reason: rephrase the point

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Contributor [harryjackson1221](https://wordpress.org/support/users/harryjackson1221/)
 * (@harryjackson1221)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/html-minify-cdata-issue/#post-12138351)
 * Hi [@disturbed-pixel](https://wordpress.org/support/users/disturbed-pixel/)
 * Sorry to hear you are having an issue with minify.
 * I would love to see what we can do to help to resolve the issue you are facing.
   What HTML minify engine are you using?
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/html-minify-cdata-issue/#post-12170219)
 * No activity dor a week. Marking topic as resolved!
 *  Thread Starter [disturbed-pixel](https://wordpress.org/support/users/disturbed-pixel/)
 * (@disturbed-pixel)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/html-minify-cdata-issue/#post-12176155)
 * Sorry, not had a chance to get back to you
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/html-minify-cdata-issue/#post-12176167)
 * Hello [@disturbed-pixel](https://wordpress.org/support/users/disturbed-pixel/)
 * No problem, can you please share What HTML minify engine are you using?
 *  Thread Starter [disturbed-pixel](https://wordpress.org/support/users/disturbed-pixel/)
 * (@disturbed-pixel)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/html-minify-cdata-issue/#post-12176179)
 * I was using the default minification engine, i had minify inline JS enabled.
 * Since, i have made further tweaks and not experiencing this issue at present,(
   cant remember the settings) unfortunately i have another issue now that i will
   write up.
 * Thanks
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/html-minify-cdata-issue/#post-12176204)
 * Hello,
    I am glad to know this issue is resolved!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘HTML Minify -> CDATA Issue’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

## Tags

 * [cdata](https://wordpress.org/support/topic-tag/cdata/)
 * [html](https://wordpress.org/support/topic-tag/html/)
 * [W3TC](https://wordpress.org/support/topic-tag/w3tc/)

 * 6 replies
 * 3 participants
 * Last reply from: [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/html-minify-cdata-issue/#post-12176204)
 * Status: resolved