Title: “Uncaught SyntaxError: Unexpected token
Last modified: March 22, 2021

---

# “Uncaught SyntaxError: Unexpected token

 *  Resolved [woodstock0137](https://wordpress.org/support/users/woodstock0137/)
 * (@woodstock0137)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/)
 * Hey, from the last few days I have noticed some weird things on my website [http://www.Topbest7.in](http://www.Topbest7.in)
   
   My homepage suddenly appears to be showing images of different alignment and 
   the Top Menu goes off from. I have tried clearing caches on several levels (server,
   webpage, chrome, from the admin dashboard), but the problem seems to return after
   a few hours. Today, when I checked the site at Google developer tools, it showed
   one error “Uncaught SyntaxError: Unexpected token and it points to ——-
 * autoptimize_40bea9e042e40f2d765ac0e84a5913ff.js:1 Uncaught SyntaxError: Unexpected
   token ‘<‘
 * ——–
    I am not very techy, so I don’t what’s wrong with the plugin in this case?
   Sorry, I can’t seem to attach screenshots, so you will have to check the site
   mentioned above
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Funcaught-syntaxerror-unexpected-token-28%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/page/2/?output_format=md)

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14221313)
 * Thanks for re-posting woodstock0137 🙂
 * I’ve looked at the site and don’t see the JS error you mention and (at first 
   sight) I don’t see a difference between the site with AO on or off (by adding`?
   ao_noptimize=1` to the URL). Do you currently see the site broken? Can you upload
   some screenshots to e.g. imgur.com and shere the URL(‘s) here?
 * frank
 *  Thread Starter [woodstock0137](https://wordpress.org/support/users/woodstock0137/)
 * (@woodstock0137)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14223663)
 * Hi Frank, thanks for coming back. Yes, like I said in my note the issue is on
   and off. When I clear dynamic cache from my Siteground hosting panel, the issue
   seems to be resolved, but that shouldn’t be a permanent solution.
    When I wrote
   this post yesterday, the site was broken.
 * I have mentioned the below URLs (taken yesterday) —
 * [https://imgur.com/ZWetQ8F](https://imgur.com/ZWetQ8F)
    [https://imgur.com/R9jQBp5](https://imgur.com/R9jQBp5)
   [https://imgur.com/EhZpAHp](https://imgur.com/EhZpAHp)
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14223741)
 * I *think* the cached page at Siteground dynamic cache is at that moment pointing
   to a missing Autoptimized JS-file due to the AO cache having been cleared (by
   you or by a “rogue” plugin?) which results in a 404-error which seems to be redirected
   to the homepage. Clearing the SG cache fixes that as the page will be regenerated
   with links of existing AO-files.
 * So the questions:
    * are you clearing the AO cache manually? or did you install
   a plugin to do that? or might you indeed have a “rogue” theme or plugin doing
   that? * normally AO has a “404 handler” but you have something else “hijacking”
   the 404 and redirecting to the homepage -> try to find out what is doing that
   and see if you can finetune (or disable) it to ensure AO can handle the 404’s
   in a nicer manner (redirecting to [https://www.topbest7.in/wp-content/cache/autoptimize/js/autoptimize_fallback.js](https://www.topbest7.in/wp-content/cache/autoptimize/js/autoptimize_fallback.js))
 * frank
 *  [Hristo Pandjarov](https://wordpress.org/support/users/hristo-sg/)
 * (@hristo-sg)
 * SiteGround Representative
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14223763)
 * We (SiteGround) turned the Dynamic caching on by default. So either use the SG
   Optimizer plugin or disable it completely following this article: [https://www.siteground.com/kb/disable-dynamic-caching-website/](https://www.siteground.com/kb/disable-dynamic-caching-website/)
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14224355)
 * doubt OP wants to disable page caching, but thanks for dropping by Hristo and
   I’m pretty sure things can be configured so AO & SG-O work together flawlessly?
   😉
 *  Thread Starter [woodstock0137](https://wordpress.org/support/users/woodstock0137/)
 * (@woodstock0137)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14224918)
 * Hi Frank, When i reached out to SG with this problem, they did uninstall the 
   SG Optimizer plugin on my WordPress site, so the recommendation to disable the
   plugin is null. As far as other plugins are concerned, I see I have
 * 1. Asset clean up
    2. Autooptimize 3. WP Fastest Cache
 * To answer your question, I sometimes clear the cache manually, besides that Autooptimize
   plugin do that from the backend.
 * Do let me know in simple language please what I need to do here. Thanks a ton
   for your efforts here.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14224999)
 * OK, but in that case you need to follow the info on [https://www.siteground.com/kb/disable-dynamic-caching-website/](https://www.siteground.com/kb/disable-dynamic-caching-website/)
   to ensure the page isn’t cached by both SG and WP Fastest Cache?
 * And if you clear AO’s cache ensure to clear WPFC’s too.
 *  Thread Starter [woodstock0137](https://wordpress.org/support/users/woodstock0137/)
 * (@woodstock0137)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14225137)
 * I am sorry I am a bit lost here, the above link says —
 * “Dynamic Caching is a full-page caching mechanism powered by NGINX. It is activated
   by default on a server level and, even if you do not have the SG Optimizer plugin
   installed, we will still cache your WordPress. However, the SG Optimizer allows
   you to have much more control over this process and we highly recommend that 
   you use it for the best dynamic cache results and for full access to the configuration
   options”
 * To be clear, on my WP dashboard, I don’t have SG-O plugin, so should I
 * 1).Download SG-O plugin
    2).Disable Dynamic Cache
 * If I download SG-O plugin, will that not conflict with the installed caching 
   plugins?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14225256)
 * problem is now that you have 2 page caches; SG nginx (dynamic cache) AND WP fastest
   cache. you should ideally only have one and that one should be manageable from
   within WordPress to allow you to clear the page cache if needed.
 * so in my opinion (although I am not an expert on SG-hosting) you should either(
   a) keep WPFC and disable SG’s dynamic caching (as explained in the article) OR
   (
   b) remove WPFC and install SG-optimizer instead (and make sure it does not optimize
   CSS/ JS as that you have AO doing).
 *  [Hristo Pandjarov](https://wordpress.org/support/users/hristo-sg/)
 * (@hristo-sg)
 * SiteGround Representative
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14226722)
 * SG Optimizer can work well with AO just don’t duplicate functionality. If you’re
   minifying in AO, disable minification in SGO and vise versa. Keep the Dynamic
   caching on and make sure the Autoflush is on. When AO regenerates styles, etc.
   that should trigger cache purge and you will see the changes right away.
 *  Thread Starter [woodstock0137](https://wordpress.org/support/users/woodstock0137/)
 * (@woodstock0137)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14232089)
 * > [View post on imgur.com](https://imgur.com/jIohTfv)
 * > [View post on imgur.com](https://imgur.com/cWijw6B)
 * Taking a look at these screenshots, do you think there is a clash of settings
   here which is interfering with the site? I published a post yesterday, which 
   was not visible until I had to flush out the dynamic cache from SG account.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14232136)
 * yes, please disable “minify HTML” and “minify CSS” in WPFC.
 * but the issue about having to flush dynamic cache is entirely different: if you
   want to keep WP Fastest Cache you will have to disable SG’s NGINX page cache.
   alternatively disable WPFC and install SG-optimizer.
 *  Thread Starter [woodstock0137](https://wordpress.org/support/users/woodstock0137/)
 * (@woodstock0137)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14232625)
 * Hi, I have now
 * 1. Minify HTML and Minify CSS on WPFC
    2. Delete dynamic caching through HTAccess
   file
 * The issue seems to be okay from my end, can you validate from your end if it’s
   all good now?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14232656)
 * so if (1) means “off” on WPFC then OK
 * re. (2) yes, that should do (although this is not my area of expertise, but Hristo
   knows 🙂 )
 *  Thread Starter [woodstock0137](https://wordpress.org/support/users/woodstock0137/)
 * (@woodstock0137)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/#post-14232964)
 * Yes for point 1, i have unchecked the options for minify HTML/CSS

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/page/2/?output_format=md)

The topic ‘“Uncaught SyntaxError: Unexpected token’ 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/)

 * 16 replies
 * 3 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/uncaught-syntaxerror-unexpected-token-28/page/2/#post-14233121)
 * Status: resolved