Support » Plugin: Autoptimize » bug in 1.8.3: inline javascript between comment tags broken

  • ResolvedPlugin Author Frank Goossens


    Afraid by solving one bug (comment tags that contained javascript or css were not ignored) another one got introduced; inline javascript between comment tags (as used to be done not to affect old browsers) gets broken.

    A fix for this is coming soon (Monday or Tuesday), but for those who want to fix this now;

    1. open /wp-content/plugins/autoptimize/classes/autoptimizeScripts.php
    2. on line 158 (before the “//Check for already-minified code”) add this:
      $this->jscode = $this->restore_comments($this->jscode);
    3. save changes and empty autoptimize cache

    For those implementing this; do confirm if solves your issues!

    (theoretically the same could happen with style-tags containing HTML-comments, but the chances of that happening are smaller, no “historic notation” to be taken into account)

    sorry for the trouble guys & girls!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Frank Goossens


    Forget about the fix above (which was not complete), just install this test-version of 1.8.4 and confirm if this works or not.

    Plugin Author Frank Goossens


    1.8.4 got release a couple of hours ago, this is fixed now.

    When Google Tag Manager is used, the script is moved to the .js in at the end of the page. It seems this occasionally causes issues, where the tags are not loaded. I am choosing now to only combine the Javascript in the head, so the script in the Tag Manager is preserved.

    Plugin Author Frank Goossens


    Morgend Lijndiensten;
    Can’t you just exclude that script from optimization?


    I am not sure, but I didn’t think so, since it’s an inline script:

    <!-- Google Tag Manager -->
    <noscript><iframe src="//"
    height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    <!-- End Google Tag Manager -->
    Plugin Author Frank Goossens


    I’d assume excluding on “gtm.start” or “googletagmanager” would work. Did you try that?

    Either gtm.start or googletagmanager, they both do the trick. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘bug in 1.8.3: inline javascript between comment tags broken’ is closed to new replies.