Disqus On AJAX Or Turbolinks Site

Posted By Weston Ganger

On an AJAX or Turbolinks site with disqus you need to do some extra checking to see if it needs to be reset or instantiated.

<div id="disqus_thread"></div>
<script type="text/javascript">
  if(typeof DISQUS === "undefined"){
    var disqus_shortname = 'your_shortname'; // required: replace example with your forum shortname

    (function() {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = "//" + disqus_shortname + '.disqus.com/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
      reload: true,
      config: function () {
        this.page.identifier = document.title;
        this.page.url = location.href;

**Credits to Yos Riady for this solutions

Related External Links:

Article Topic:Software Development - Web Development

Date:March 22, 2015