Title: wp_localize_script() triggers Uncaught SyntaxError: Unexpected token &#8216;-&#8216;
Last modified: January 17, 2021

---

# wp_localize_script() triggers Uncaught SyntaxError: Unexpected token ‘-‘

 *  Resolved [Larry Daniele](https://wordpress.org/support/users/larrydaniele/)
 * (@larrydaniele)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/wp_localize_script-triggers-uncaught-syntaxerror-unexpected-token/)
 * Thanks for a handy plugin!
 * In show-hooks.php line 248, there’s this line of code:
 * `wp_localize_script('abc-main-js', 'abc-main-js', array(`
 * The second parameter (‘abc-main-js’) is supposed to be a valid JavaScript variable
   name, but JavaScript does not allow “-” in variable names, so in the browser 
   console I see:
 * > JavaScript Uncaught SyntaxError: Unexpected token ‘-‘
 * Changing this second parameter to ‘abc_main_js’ fixes the problem.

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

 *  Plugin Contributor [Rafiqul Islam](https://wordpress.org/support/users/rafiq91/)
 * (@rafiq91)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/wp_localize_script-triggers-uncaught-syntaxerror-unexpected-token/#post-13966503)
 * Hi [@larrydaniele](https://wordpress.org/support/users/larrydaniele/)
 * Thanks for reporting the issue and apologize for the delay. I have updated the
   plugin, please update it now.
 * Regards,
    Rafiq
 *  Thread Starter [Larry Daniele](https://wordpress.org/support/users/larrydaniele/)
 * (@larrydaniele)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/wp_localize_script-triggers-uncaught-syntaxerror-unexpected-token/#post-13966814)
 * Thanks, Rafiq. With Show Hooks v0.1.4 I no longer see this error.
 * I am seeing a new error with this version:
 * > Uncaught SyntaxError: Unexpected token ‘<‘
 * at URL [https://dev.stoneharborpoa.org/?abc-hooks=show-action-hooks](https://dev.stoneharborpoa.org/?abc-hooks=show-action-hooks).

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

The topic ‘wp_localize_script() triggers Uncaught SyntaxError: Unexpected token ‘-‘’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/show-hooks_98b0bd.svg)
 * [Show Hooks](https://wordpress.org/plugins/show-hooks/)
 * [Support Threads](https://wordpress.org/support/plugin/show-hooks/)
 * [Active Topics](https://wordpress.org/support/plugin/show-hooks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/show-hooks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/show-hooks/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Larry Daniele](https://wordpress.org/support/users/larrydaniele/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/wp_localize_script-triggers-uncaught-syntaxerror-unexpected-token/#post-13966814)
 * Status: resolved