速度改善

■レンダリングを妨げるリソースを除外する
javaにasyncを付ける
if(!(is_admin())){
function replace_scripttag($tag){
if(!preg_match(‘/defer/’,$tag)){
return str_replace(“type=’text/javascript'”,’async’,$tag);
}
return $tag;
}
add_filter(‘script_loader_tag’,’replace_scripttag’);
}

場所を下部に
//レンダリングブロック対策(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’);

//レンダリングブロック対策(プラグインがヘッダーに入れるCSSを一旦解除
function dequeue_css_header() {
wp_dequeue_style(‘wp-pagenavi’);
wp_dequeue_style(‘sb_instagram_styles’);
wp_dequeue_style(‘sb-font-awesome’);
wp_dequeue_style(‘mw-wp-form’);
}
add_action(‘wp_enqueue_scripts’, ‘dequeue_css_header’);
//CSSファイルをフッターに出力
function enqueue_css_footer(){
wp_enqueue_style(‘wp-pagenavi’);
wp_enqueue_style(‘sb_instagram_styles’);
wp_enqueue_style(‘sb-font-awesome’);
wp_enqueue_style(‘mw-wp-form’);
}
add_action(‘wp_footer’, ‘enqueue_css_footer’);

Google