Title: bug in 1.8.3: inline javascript between comment tags broken
Last modified: August 21, 2016

---

# bug in 1.8.3: inline javascript between comment tags broken

 *  ResolvedPlugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/bug-in-183-inline-javascript-between-comment-tags-broken/)
 * 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:
    3.     ```
           $this->jscode = $this->restore_comments($this->jscode);
           ```
       
    4. 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!
    frank
 * [https://wordpress.org/plugins/autoptimize/](https://wordpress.org/plugins/autoptimize/)

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

 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/bug-in-183-inline-javascript-between-comment-tags-broken/#post-4757956)
 * Forget about the fix above (which was not complete), just install [this test-version of 1.8.4](http://downloads.wordpress.org/plugin/autoptimize.zip)
   and confirm if this works or not.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/bug-in-183-inline-javascript-between-comment-tags-broken/#post-4757964)
 * 1.8.4 got release a couple of hours ago, this is fixed now.
 *  [lijndiensten](https://wordpress.org/support/users/lijndiensten/)
 * (@lijndiensten)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/bug-in-183-inline-javascript-between-comment-tags-broken/#post-4758038)
 * 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](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/bug-in-183-inline-javascript-between-comment-tags-broken/#post-4758039)
 * Morgend Lijndiensten;
    Can’t you just exclude that script from optimization?
 * frank
 *  [lijndiensten](https://wordpress.org/support/users/lijndiensten/)
 * (@lijndiensten)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/bug-in-183-inline-javascript-between-comment-tags-broken/#post-4758040)
 * I am not sure, but I didn’t think so, since it’s an inline script:
 *     ```
       <!-- Google Tag Manager -->
       <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXX"
       height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
       <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
       new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
       j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
       '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
       })(window,document,'script','dataLayer','GTM-XXXX');</script>
       <!-- End Google Tag Manager -->
       ```
   
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/bug-in-183-inline-javascript-between-comment-tags-broken/#post-4758041)
 * I’d assume excluding on “gtm.start” or “googletagmanager” would work. Did you
   try that?
 *  [lijndiensten](https://wordpress.org/support/users/lijndiensten/)
 * (@lijndiensten)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/bug-in-183-inline-javascript-between-comment-tags-broken/#post-4758042)
 * 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.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [lijndiensten](https://wordpress.org/support/users/lijndiensten/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/bug-in-183-inline-javascript-between-comment-tags-broken/#post-4758042)
 * Status: resolved