Cannot deregister a script using wp_dequeue_script

I am trying to get rig of the Disqus script on my front page, but unfortunately I cannot manage how to do this.

Here is a little story of the steps I’ve done.

  1. Find the script name in the source code files of the plugin

wp_register_script( ‘dsq_count_script’, plugins_url(
‘/media/js/count.js’, FILE ) );
wp_localize_script( ‘dsq_count_script’, ‘countVars’, $count_vars );
wp_enqueue_script( ‘dsq_count_script’, plugins_url( ‘/media/js/count.js’, FILE ) );

  1. Add an action for the wp_print_scripts hook

    add_action('wp_print_scripts', array($this, 'deregister_unused_scripts'), 100);
  2. Implement deregister_unused_scripts function

    public function deregister_unused_scripts()

Still doesn’t work.

I also tried another hook

    add_action('wp_footer', array($this, 'deregister_unused_scripts'), 100);

But this didn’t help as well.

Read more here: Cannot deregister a script using wp_dequeue_script

Leave a Reply

Your email address will not be published. Required fields are marked *