Rahul Arora

Load Disqus Comments on “click” event

Load Disqus on Demand

Disqus commenting system is everywhere these days. It allows you to add comments section to any web page you manage. You can moderate comments with Disqus, without having to worry about spam. The best part is it doesn’t cost you even a dime.

Disqus makes use of AJAX to fetch comments, so you don’t need to care much about the load time. But here are couple of cool ways to control the loading of comments, that may help you improve the load time even more.

Note that this is little bit more advanced than installing WordPress plugins. You need to dig in the code to get things done.

The Code

That means Disqus will only load when the visitor clicks on a particular button or link. Just copy-paste the below given code where you want the “Load Comments” button to appear:

<div id="disqus_thread"></div>
<div id="disqus_loader">
<button onclick='function(){
        var u = "YOUR_DISQUS_USERNAME",
        s = document.createElement('script'),
        e = document.getElementById("disqus_loader");
	s.src = "http://" +u+ ".disqus.com/embed.js";
	s.async = 'true';
'>Load Comments</button>

That’s it. You should now see the “Load Comments” button at that part of your website now. Click it to test your implementation.

Tip: Make it sure to properly highlight the button. It should invite people to click and that’s what you want, right?


In case you are utilizing jQuery on your sites and want to do the above code the jQuery way:

<div id="disqus_thread"></div>
<div id="disqus_loader">
<button onclick='
Post a Comment


  • Make it sure to replace YOUR_DISQUS_USERNAME to your Disqus username. Your Disqus username is the name you use to log into your Disqus account.
  • The div with id disqus_thread will be the place where the comments will be loaded on using any of the above two snippets.
  • Don’t go for the jQuery method if you are not already using jQuery library on your website. Using it just to load comments is not a good idea.
About the author

I'm Rahul Arora. I'm a Web developer, with expertise in CSS3, JavaScript, and WordPress. More about me →