Many Disqus Modules On A Single Page

Posted By Weston Ganger

For many SPA's or AJAX sites loading multiple disqus modules per page can be a pain.

You can only show one disqus module at a time. So you must use a button or something that shows and hides on click.

//config
var disqus_shortname = 'disqusShortname';
var disqus_identifier = 'disqusIdentifier';
var disqus_title = 'postTitle';
var disqus_url = 'http://mysite.com/my_url';

if(typeof(DISQUS) === 'undefined'){
  (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);
  })();
} else {
  DISQUS.reset({
    reload: true,
    config: function() {
      this.page.identifier = disqus_url;
      this.page.url = disqus_url;
      this.page.title = disqus_title;
    }
  });
}

Related External Links:

Article Topic:Software Development - Javascript

Date:September 05, 2015