Why I love Disqus
Once upon a time if I wanted comments on a website, I would do them myself, tediously tackling problems solved a dozen times before to deliver an intuitive system. But today is a new day and I wouldn't dream of writing comment code unless I really had to.
An essential part of any blogging engine is allowing your readers to give you feedback and create discussions around a topic. There are few things worse than landing on a blog, reading some tripe and not being able to flame the writer for it.
In the dozen-or-so iterations of ThePCSpy.com, I’ve gone through four major home-made blogging engines: the first two in classic ASP, the second in some very clever, very verbose ASP.NET and the latest in Django.
Before the current implementation, each engine needed me to implement a comments feature. The first two were basic and the ASP.NET version was several hundred lines long with clever sorting, nesting, editing and AJAX. When I moved to Django I had three choices:
- Re-re-re-re-re-reinvent the wheel, bringing everything I had learned to Python/Django,
- Use a pre-made Django app like django-threadedcomments and create a nice interface for people, or
- Use something off-site, like Disqus
#2 require serious work
Doing comments well requires an authentication system (that I had implemented in previous iterations) which, in turn, requires registration, forgotten password, login and logout pages. Django does most of this very simply but then you have to hook that into your comments to allow a dual-system of registered and anonymous comments. It’s a problem I had solved for the ASP.NET version but it was ugly and as I said, hundreds of lines of logic that could not be easily ported to Python.
Then there are features like subscriptions, moderation, banning users… Things you forget about when you first dive into writing your own comments section. Things that take even more time and even more logic.
And then there’s performance. Showing comments, pulling up user details, getting the nesting and paging done correctly, implementing the AJAX to run effectively, partial caching of the page so comments update immediately without having to regenerate the main page, optimising SQL queries… All things that take serious consideration and design to get right.
At this point I started to get a headache. I didn’t want to build something from scratch or customise something to death. I just wanted comments on the new site so I had a look at option
#3. I looked at Disqus and IntenseDebate. I already had an account with both from commenting on other people’s blogs but I decided on a coin-flip and ended up with Disqus, itself a Django-powered service.
Implementing it was beyond simple. After setting up the site settings on Disqus, I added this to my posts’ template:
Refreshed the page and I could add new comments to the blog.
Porting the old comments was slightly harder
When I dumped my old ASP.NET site, all I had of the MS SQL Server database was JSON dumps of the posts and comments. I wrote a little script to import both, posts into my new
BlogPost model and comments into
django.contrib.comments. This meant I now had all the data available from within Django but I needed to upload the comment data to Disqus.
Thankfully there’s another app called
django-disqus that really helps here. It has a
manage.py function that allows you to export
django.contrib.comments posts to Disqus so I installed it and ran
After a few botched attempts and then a few hours it had uploaded all the comments on all the old posts and I removed both
django-disqus as neither were needed anymore.
Now I have:
- A great out-the-box design
- Solid caching on this site (== faster server)
- No need for a user-facing authentication system (== faster server)
- Lower bandwidth and database requirements (== faster server)
- Much more simple Django stack (== less memory consumption == faster server)
- Good comment tools (subscriptions/moderation/banning/reporting/etc)
All for free with a tiny bit of effort.
There are some downsides
The most evident is that if Disqus goes down, shuts down, gets hacked, etc, it effects me. I have to have a certain amount of trust.
Any off-site comment solution is also going to be useless if you needed to control who was posting. In this cases you probably already have user authentication so you’d want to use something that hooked directly into that database.
But all-in-all, a great result
For the purposes of blogging, I have only compliments for Disqus. It has saved me several days of legwork, countless gigabytes of bandwidth, hours of CPU time and provides me (and you, my readers) a better commenting experience.
If you’re writing your own blog (or even if you’re using something like Wordpress), I’d strongly consider getting your comments on Disqus (or other) and giving yourself and your server a well earned break.