Title: Uncaught SyntaxError: Unexpected Token
Last modified: August 24, 2016

---

# Uncaught SyntaxError: Unexpected Token

 *  [info2grow](https://wordpress.org/support/users/info2grow/)
 * (@info2grow)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-9/)
 * After enabling the plugin on our site [http://www.naturaldermis.com](http://www.naturaldermis.com)
   we started getting console errors on the homepage. Only if a user visited another
   page and then came page to the homepage. The error caused half the page not to
   load.
 * The error pointed to this script on the homepage
 * <script type=”application/ld+json”>{ “@context”: “[http://schema.org&#8221](http://schema.org&#8221);,”
   @type”: “WebSite”,”url”: “[http://naturaldermis.com/&#8221](http://naturaldermis.com/&#8221);,”
   potentialAction”: {“@type”: “SearchAction”,”target”: “[http://naturaldermis.com/?s=](http://naturaldermis.com/?s=){
   search_term}”,”query-input”: “required name=search_term”}}</script>
 * We had to disable the plugin.
 * Any ideas what would cause this?
 * [https://wordpress.org/plugins/wordpress-seo/](https://wordpress.org/plugins/wordpress-seo/)

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

 *  [coachie](https://wordpress.org/support/users/coachie/)
 * (@coachie)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-9/#post-5977731)
 * Hi Info2grow, how did you fix it?
 *  Thread Starter [info2grow](https://wordpress.org/support/users/info2grow/)
 * (@info2grow)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-9/#post-5977732)
 * Never heard back so we uninstalled it.
 *  [coachie](https://wordpress.org/support/users/coachie/)
 * (@coachie)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-9/#post-5977733)
 * Thanks for the reply info2grow.
 * I did following, knowing that this is not clever because of updates coming.
 * file: wordpress-seo/frontend/class-frontend.php
 * //echo “<script type=’application/ld+json’>”, json_encode( $this->data ), ‘</
   script>’, “\n”;
 * //$this->output( ‘website’ );
 *  [anuj-kumar](https://wordpress.org/support/users/anuj-kumar-1/)
 * (@anuj-kumar-1)
 * [10 years, 12 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-9/#post-5977748)
 * I faced the same issue, and have been able to resolve it.
 * Looks like the browser isn’t able to recognize ld+json format outside the body
   tags of the page. The plugin adds the data before the body tag, and hence the
   error. If the structured data is written inside the body tags, it works totally
   fine.
    Initially I tried using a try catch block as below:
 *     ```
       var t = {
           //json data
       };
       try {
           jQuery.globalEval(t)
       } catch (e) {
           console.log(e)
       }
       ```
   
 * but Google wasn’t able to understand this, so I had to revert the changes.
    Then
   after more hits and trials, I was able to fix it: file: wordpress-seo/frontend/
   class-frontend.php (Version: upto 2.1.1) Line: 1914
 *     ```
       echo "<script type='application/ld+json'>", json_encode( array($this->data) ), '</script>', "\n";
       ```
   
 * which has been verified to work, although, I would really appreciate if someone
   could provide a better fix than this.
    It is strange, how such a major issue 
   went unnoticed from the plugin development team. Let’s hope they fix it soon.

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

The topic ‘Uncaught SyntaxError: Unexpected Token’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

## Tags

 * [syntax error](https://wordpress.org/support/topic-tag/syntax-error/)
 * [unexpected token](https://wordpress.org/support/topic-tag/unexpected-token/)

 * 4 replies
 * 3 participants
 * Last reply from: [anuj-kumar](https://wordpress.org/support/users/anuj-kumar-1/)
 * Last activity: [10 years, 12 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-9/#post-5977748)
 * Status: not resolved