Search code examples
javascriptlaraveldisqus

disqus comment count not loading when using identifier


I have an overview page of episodes where I want to display the comment for each episode. However nothing shows up after following the steps indicated by Disqus' manual. It only works when I use the data-disqus-url attribute. But I prefer to use the unique identifier for obvious reasons.

I iterate over each episode to display its info including comment count like so:

<span class="disqus-comment-count" data-disqus-identifier="{{$episode->id}}"></span>

I load the javascript at the end of the page right before the body like so:

<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES * * */
    var disqus_shortname = 'animekyun';
    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function () {
        var s = document.createElement('script');
        s.async = true;
        s.type = 'text/javascript';
        s.src = '//' + disqus_shortname + '.disqus.com/count.js';
        (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
    }());
</script>

In the actual episode view I have the following:

<div id="disqus_thread"></div>
<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES * * */
    var disqus_shortname = 'animekyun';
    var disqus_identifier = '{{$episode->id}}';
    /* * * DON'T EDIT BELOW THIS LINE * * */
    (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);
    })();
</script>

I'm not using a CMS. I'm using laravel instead.


Solution

  • According to a disqus dev, the actual count is generated once the comment page has been loaded. It will then take a couple of minutes for the server to sync. In other words: load the page, wait a minute and the comment count will show up.