Cannot deregister a script using wp_deregister_script

When attempting to dequeue a script, we need to hook in after the script is enqueued, but before it’s printed. In this case, the Disqus plugin is using the wp_footer hook at a priority of 10 to enqueue the scripts. The footer scripts get printed during wp_footer at a priority of 20. So we should be able to hook into wp_footer at a priority of 11 and dequeue the script.

add_action( 'wp_footer', 'wpse_262301_wp_footer', 11 );
function wpse_262301_wp_footer() { 
  wp_dequeue_script( 'dsq_count_script' ); 
}

Leave a Comment