April 9, 2016

Fixing Disqus comments when using Cloudflare

Most people when they find Disqus does not work with Cloudflare due to rocket loader just turn it off. By default its on automatic. There is a solution though.

Image of Cloudflare Rocket loader

I have managed to get it working by using the handy parameter data-cfasync="false" This tells Rocket loader not to touch these scripts. This allows the rest of the site to get the rocket loader benefit without breaking Disqus. Here is an snipet of the Disqus code with the parameter added:

 <div id="disqus_thread"></div>
<script data-cfasync="false" type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_config = function () {
        this.page.url = '{{@blog.url}}{{url}}';
        this.page.identifier = '{{post.id}}';
    };

This method should work for any script that causes issues. Flush your cloudflare cache and problem solved!

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket
Comments powered by Disqus