Remove Disqus JavaScript from homepage

Hey WordPress friends,

I’m using the Disqus comment system plugin, which is working fine. My homepage is just a collection if recent posts and therefore not having the option to leave a comment (as desired).

Unfortunately, I still see that the Disqus plugin is rendering JavaScript output within the homepage and would like to get rid of this.

I've Tried the following but without luck. Any help is appreciated! Thanks

function block_disqus_count() {
if ( is_front_page())
    remove_filter('output_count_js', 'dsq_output_count_js');
}

add_action( 'block_disqus_count' , 'block_disqus_count');

Topic disqus functions homepage Wordpress

Category Web


You should deregister it. Add this function into your functions.php:

add_action( 'wp_enqueue_scripts', 'disqus_scripts' );

function disqus_scripts() {
  if(is_front_page()) {
    wp_deregister_script('disqus_count');
  }
}

Solved it by altering the file disqus.php. First find function

function dsq_output_count_js() {

Add the following check before the function tries to output the JS

 if ( ! is_front_page() ) { ?> <script type="text/javascript"> 

I’m using this until Disqus created the option to configure this. Thanks for the help.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.