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:

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:

  1. Pick a public GitHub repo to hold the discussions. A dedicated one is fine, e.g. yourname/blog-comments.
  2. Enable Discussions on that repo.
  3. Install the giscus GitHub App on it.
  4. Go to giscus.app, fill in the repo and mapping options, copy the resulting <script> tag.
  5. 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:

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.