Title: ES6 template string error
Last modified: September 1, 2016

---

# ES6 template string error

 *  Resolved [fengerzh](https://wordpress.org/support/users/fengerzh/)
 * (@fengerzh)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/es6-template-string-error/)
 * If our JS file contains ES6 template string like this:
 * $(‘.act-container .proj-card[data-act_date!=${dateSelected}]’).hide();
 * (I can not put backticks in. Actually, you should change the above ‘ to backticks.)
 * For some reason, autoptimize will cause the statement fail, unless we explicitly
   let autoptimize to not include the js file in.
 * [https://wordpress.org/plugins/autoptimize/](https://wordpress.org/plugins/autoptimize/)

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

 *  Thread Starter [fengerzh](https://wordpress.org/support/users/fengerzh/)
 * (@fengerzh)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/es6-template-string-error/#post-7577249)
 * \`
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/es6-template-string-error/#post-7577325)
 * interesting fengerzh…
 * some questions:
    * do you see an error in your browser console? * when comparing
   the JS before optimization with the one after, what differences do you see? *
   do you happen to have example-code which does not require jquery? does optimizing
   that fail as well? * could you create a small fiddle on [http://jsfiddle.net](http://jsfiddle.net)(
   and post the link here) with the simplest example possible (which breaks when
   optimized)?
 * frank
 *  Thread Starter [fengerzh](https://wordpress.org/support/users/fengerzh/)
 * (@fengerzh)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/es6-template-string-error/#post-7577463)
 * 1. I did not see any error in browser console.
 * 2. I found there is a space missed in the optimized code.
    The original code 
   is as below: (please change the ‘ to backticks, I cannot put it here) $(‘.act-
   container .proj-card[data-act_date!=${dateSelected}]’).hide(); After optimize,
   it became this: $(‘.act-container.proj-card[data-act_date!=${dateSelected}]’).
   hide(); You can notice there is a space is missing.
 * 3. I create a small piece of code in jsfiddle: [https://jsfiddle.net/6jhcpeLL/](https://jsfiddle.net/6jhcpeLL/)
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/es6-template-string-error/#post-7577471)
 * great, I’ll dig in! 🙂
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/es6-template-string-error/#post-7577480)
 * OK, I [have a fix on the development version of AO](https://github.com/futtta/autoptimize/commit/0643d50e8dce7dc0e31c92bf80545a6ef5d7c7cd).
   I’ve also [issued a pull request against Mr Clay’s jsmin-php](https://github.com/mrclay/jsmin-php/pull/6),
   which is the JS minifier that AO uses, as it’s in that component where the fix
   actually is applied.
 * If you want, you can download what will essentially become AO 2.0.3 from GitHub
   and overwrite wp-content/plugins/autoptimize/ with the contents of autoptimize-
   master/ from the zipfile. Let me know if that fixes things for you!
 * frank
 *  Thread Starter [fengerzh](https://wordpress.org/support/users/fengerzh/)
 * (@fengerzh)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/es6-template-string-error/#post-7577498)
 * Yes, that solved the problem. Great!
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/es6-template-string-error/#post-7577514)
 * I just backported [Mr. Clay’s more elaborate fix](https://github.com/mrclay/jsmin-php/commit/84e3cff6c49192c340b6bb97f28a3935e0c732cb),
   would be great if you could [re-download the to-be 2.0.3](https://github.com/futtta/autoptimize/archive/master.zip)&
   test that as well fengerzh to be sure all is well?
 *  Thread Starter [fengerzh](https://wordpress.org/support/users/fengerzh/)
 * (@fengerzh)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/es6-template-string-error/#post-7577528)
 * tested, no problem.

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

The topic ‘ES6 template string error’ 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/)

## Tags

 * [es6](https://wordpress.org/support/topic-tag/es6/)

 * 8 replies
 * 2 participants
 * Last reply from: [fengerzh](https://wordpress.org/support/users/fengerzh/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/es6-template-string-error/#post-7577528)
 * Status: resolved