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.
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 ) );
Add an action for the
wp_print_scripts
hookadd_action('wp_print_scripts', array($this, 'deregister_unused_scripts'), 100);
Implement
deregister_unused_scripts
functionpublic function deregister_unused_scripts() { wp_dequeue_script('dsq_count_script'); wp_deregister_script('dsq_count_script'); }
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, I still get an output in the footer.
<script type='text/javascript'>
/* <![CDATA[ */
var countVars = {"disqusShortname":"myname"};
/* ]]> */
</script>
<script type='text/javascript' src='http://myurl.net/wp-content/plugins/disqus-comment-system/media/js/count.js?ver=4.7.3'></script>
What can be wrong ?
EDIT
Here is the action used to register the plugin script.
add_action('wp_footer', 'dsq_output_footer_comment_js');