javascriptcommentsadsdisqus

How do I disable or hide the unwanted Disqus ads on my website?


Imagine that one day, suddenly, random ads started appearing on your website...

Recently Disqus started forcing unwanted ads inside of the Disqus comments, displaying those nasty ads on your website(s) without your knowing. It seems that they only target the sites with "big enough" daily traffic or use some other arbitrary criteria, so the ads do not appear on all the websites, but only on relatively busy ones.

This way Disqus "forces" you to upgrade to the paid subscription plan - for the paid users these ads become optional (i.e. you can disable them in your Disqus admin panel).

What to do if you don't want to pay? How to disable these ads? Is there an easy, quick-fix solution for this?

At least until we have the time to switch to another commenting system.


Solution

  • As of moment of writing, it seems that popular AdBlock browser extensions successfully block the ads. However, not all of your website visitors use adblock.

    Here is a quick jQuery-based solution to hide the ads:

    (function($){
        setInterval(() => {
            $.each($('iframe'), (arr,x) => {
                let src = $(x).attr('src');
                if (src && src.match(/(ads-iframe)|(disqusads)/gi)) {
                    $(x).remove();
                }
            });
        }, 300);
    })(jQuery);
    

    Just insert it on your website after jQuery loads, on every page where the Disqus comments appear. The code checks periodically if there are Disqus ads present on your website and removes their container whatsover. You know, just in case if they'll try to re-appear.