LoginSignup
0
0

More than 5 years have passed since last update.

Disqus Wordpressプラグインのコメントスクリプトをブログ以外でロードさせない

Posted at

https://puntoapp.jp/ のパフォーマンスのチューニングをしてたら、なぜかトップページ以下のスクリプトを発見。。。

https://puntoapp.jp/wp-content/plugins/disqus-comment-system/public/js/comment_count.js

ふむ〜
Wordpressで、普通はコメントなんか使わないのに、Disqusの開発者さん不親切ですね〜

なので、取り敢えずブログ以外の投稿には、読み込まないように以下を追記!

function disable_disqus() {

   //if not blog page, remove disqus filter
   if( !is_page('blog') ) {
      wp_dequeue_script('disqus_comment');
      wp_dequeue_script('disqus_embed');
            wp_deregister_script( 'disqus_comment' );
            wp_deregister_script( 'disqus_embed' );
   }
}

//hook onto comments_template filter with priority 1
add_action( 'wp_print_scripts' , 'disable_disqus', 100 );

P.S.
WPの手軽にパフォーマンスの高いサイト制作サービス提供しています。
手軽にご相談ください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0