From Disqus to giscus. Comments without the bloat.
When I put this blog back online, the very first thing I deleted was the Disqus loader on every page.
If you have not looked at a Disqus embed in a while, it has not improved. The script pulls in third-party JavaScript, a small army of trackers, ad iframes for users not paying for Disqus Pro, and a couple of network round trips before it draws anything. For a static site that loads in under 200 ms otherwise, this is just rude.
The cleanup
The original embed lived as a script block on every post. It looked like this, roughly:
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = 'http://artemstar.com/...';
this.page.identifier = '/...';
};
// lazy-load on scroll
</script>
<noscript>Please enable JavaScript to view the comments…</noscript>One regex pass and 57 of these were gone across 19 files. Removing things is a strangely satisfying step. I wish more of my work was removing things.
What I considered
I had a short list:
- Disqus, fixed up. Pay for Pro, remove the ads, accept that you are still loading a third-party SPA. No.
utterances. Open source, GitHub-issue-backed. Lovely, but the project is sleepy and giscus is essentially its successor.giscus. Same idea as utterances — comments live in GitHub Discussions on a repo you control. Active project, good docs.- Cactus comments / Commento / IsSo. Self-hosted. I do not want a database for this blog.
- No comments at all. Honestly tempting. The signal-to-noise on most comment threads is bad. People who want to reach me can email.
I ended up between “no comments” and giscus and decided to leave the blog quiet for now. Giscus is what I would pick the moment I change my mind, so here is the setup that I would use, written down before I forget it.
giscus in five minutes
The flow is:
- Pick a public GitHub repo to hold the discussions. A dedicated one is fine, e.g.
yourname/blog-comments. - Enable Discussions on that repo.
- Install the giscus GitHub App on it.
- Go to giscus.app, fill in the repo and mapping options, copy the resulting
<script>tag. - Drop the snippet into the comments section of your post template.
The embed looks like this:
<script src="https://giscus.app/client.js"
data-repo="yourname/blog-comments"
data-repo-id="R_kg…"
data-category="General"
data-category-id="DIC_kw…"
data-mapping="pathname"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="bottom"
data-theme="light"
data-loading="lazy"
crossorigin="anonymous"
async>
</script>The two settings that actually matter are data-mapping="pathname" (so a comment thread is tied to a URL path, not a page title that I might rewrite) and data-loading="lazy" (so the comments don’t load on every page view).
The trade-offs
Things you give up by going from Disqus to giscus:
- Anonymous comments. Everyone needs a GitHub account. For a blog about Docker and Terraform that is roughly the same as the audience I had, so I don’t care. For a recipe blog, this would be a terrible choice.
- Spam moderation. Mostly not your problem now. It is just GitHub Discussions.
- Email notifications. Comes from GitHub. You can subscribe to a thread like any issue.
- Comment portability. You own a repository of Markdown discussions. If giscus ever disappears, you still have the data. With Disqus, the data was always theirs.
And the obvious nice thing — the comments box no longer makes its own little Christmas of third-party requests. The blog loads at the same speed whether the section is rendered or not, because nothing happens until the user scrolls to it.
If I end up turning comments on again, the snippet above is what goes in. If not, fewer trackers in the world, mine or anyone else’s.