Over the last few days, I have made some changes on the site to improve its speed. One of such changes was replacing the native WordPress comment system with Disqus. I changed the comment system because I thought of doing something like what Amit Agarwal has done on Labnol – make comments appear only when the visitors click on a button. This will reduce a lot of HTTP requests and in turn, help to improve site speed. I googled and then came across a post that did exactly what I was looking for!

NOTE : I have noticed that doing this will create a problem with Comment Sync, meaning, if you ever choose to leave Disqus and switch to the native WordPress comment system, all the comments might not be imported to the native WP comment system.

What we are trying to accomplish here is to load comments only when a button at the end of the page is clicked. If a visitor is really interested to leave a comment, he will do so by clicking a button. This guide is meant for WordPress, although  the same code can be used on other platforms as well.

On WordPress, go to Plugins > Editor. Select Disqus Comment System. On the right pane, click on disqus-comment-system/comments.php. (Make a backup of the file  by copying all the texts there to a text editor.) Now, replace all the texts with the one below :

Source : http://www.paulund.co.uk/ajax-disqus-comment-system

On the above code, replace “thelacunablog” with the shortname of your website. You can find it by going to Disqus Settings > General, under Site Identity. Now, save the file.

Open up any post and you should see a button that says “Load all comments and add yours”. Visitors will now need to click on the button to view/add comments.

Bonus tip : Disqus by default does not show pingbacks. You might also want to force Disqus to display them.