よもやまチョモランマ

「レンダリングを妨げるリソースの除外」対策(JS)

CSSを移しただけではほとんど効果がなかったので、今度はJSを移す。
【参考】WordPress : レンダリングをブロックしている JavaScript/CSSへの対策

//JSファイルの移動
function move_js_footer(){
  remove_action('wp_head', 'wp_print_scripts');
  remove_action('wp_head', 'wp_print_head_scripts', 9);
  remove_action('wp_head', 'wp_enqueue_scripts', 1);

  add_action('wp_footer', 'wp_print_scripts', 5);
  add_action('wp_footer', 'wp_print_head_scripts', 5);
  add_action('wp_footer', 'wp_enqueue_scripts', 5);
}
add_action('wp_enqueue_scripts', 'move_js_footer');

これをfunctionにコピペしただけで56行も減った。
CSSと違ってIDを調べたりしなくて済むのがありがたいですね。

PSIスコアは、7ずつ上がった。
今までの施策があまりにも手応えなさすぎたから、なんかすげー上がった気がする。33/73だけど。