Support » Plugin: W3 Total Cache » HTML Minify -> CDATA Issue

  • Resolved disturbed-pixel

    (@disturbed-pixel)


    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 4 months, 2 weeks ago by disturbed-pixel.
    • This topic was modified 4 months, 2 weeks ago by disturbed-pixel. Reason: rephrase the point
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.