Resolving "SyntaxError: Unexpected identifier #..." caused by Cloudflare Auto Minify

Cloudflare’s ‘Auto Minify’ feature will break recent versions of Discourse. In the browser console, you will see an error like:

Uncaught SyntaxError: Unexpected identifier '#...'

Cloudflare are aware of the issue, and have added this message to their dashboard:

Note: Please note that this feature may not be fully compatible with certain newer CSS and JS language features, which could potentially affect the functionality of the site

Unfortunately, despite this critical issue, the feature will remain enabled for existing sites until 2024-08-05. Update August 20th: the feature is still in place, and says ‘will be removed soon’

To disable this Cloudflare feature, and restore the functionality of your Discourse site, you should:

  1. Visit the ‘Content Optimization’ Section of your Cloudflare settings:

  2. Scroll down to “Auto Minify”, and uncheck all boxes

  3. In the sidebar, go to Caching → Configuration, and click “Purge Everything”

Now when you refresh your forum, things should be back in working order.

For more information on optimizing Discourse/Cloudflare, check out this topic:

18 Likes