Skip to main content

Disqus Migration - part 2 - Latest Comments widget

April 25, 2016 mgroves 0 Comments
Tags: disqus JavaScript jQuery HTTP API

One of the things that I've always liked to have on my blogs over the years is a "latest comments" widget. I like to leave all my blog posts open for comment indefinitely, and this gives users a way to see the latest comments, even if they are on very old blog posts.

Disqus doesn't have a "drop-in" JavaScript snippet to do this, but Disqus does have an extensive HTTP API that allowed me to build my own.

The terminoloy that Disqus uses was a little confusing for me, but by reading some of the docs and trying a few tests in Fiddler, I was able to see that the forums/listPosts API endpoint was the one I wanted. You'll need to make sure that you have a public key generated in order to use the endpoint. Here's the widget I wrote:

Some notes:

  • Disqus rate limits you to 1000/requests per hour. For my blog, that's probably more than enough.
  • This script depends on jQuery, but you can use something else for your DOM manipulation, even plain JavaScript if that's your jam.
  • I was at least partially inspired by Raymond Camden blogging about something similar.

Comments

Matthew D. Groves

About the Author

Matthew D. Groves lives in Central Ohio. He works remotely, loves to code, and is a Microsoft MVP.

Latest Comments

Twitter