• Resolved codifex

    (@codifex)


    I am using Autoptimize to optimize HTML, CSS, and JavaScript on a site.

    On one page a Google AdWords conversion tracking code is contained in the HTML output:

    <!-- Google Code for Anfrage Conversion Page
    In your html page, add the snippet and call
    goog_report_conversion when someone clicks on the
    chosen link or button. -->
    <script type="text/javascript">
      /* <![CDATA[ */
      goog_snippet_vars = function() {
        var w = window;
        ...
        w.google_conversion_value = 1.00;
        w.google_conversion_currency = "EUR";
        w.google_remarketing_only = false;
      }
      // DO NOT CHANGE THE CODE BELOW.
      goog_report_conversion = function(url) {
        goog_snippet_vars();
        window.google_conversion_format = "3";
        var opt = new Object();
        opt.onload_callback = function() {
        if (typeof(url) != 'undefined') {
          window.location = url;
        }
      }
      var conv_handler = window['google_trackConversion'];
      if (typeof(conv_handler) == 'function') {
        conv_handler(opt);
      }
    }
    /* ]]> */
    </script>
    <script type="text/javascript"
      src="//www.googleadservices.com/pagead/conversion_async.js">
    </script>

    Unfortunately HTML optimization seems to destroy /* <![CDATA[ */ and /* ]]> */. These code segments are minified to /* */, making Google complain.

    Is there any way to keep HTML optimization enabled and preserve these JavaScript comments?

    By the way, thank you very much for this great plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter codifex

    (@codifex)

    It seems that enclosing the script in <!--noptimize--> ... <!--/noptimize--> fixes the problem.

    Plugin Author Frank Goossens

    (@futtta)

    It seems that enclosing the script in <!--noptimize--> ... <!--/noptimize--> fixes the problem.

    it does ??

    have a nice weekend!
    frank

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude inline JavaScript containing HTML from HTML optimization’ is closed to new replies.