WordPressの速度改善についてご質問があります。
プラグイン「Autoptimize」を使用しCSSなどの圧縮をおこなっているのですが、圧縮したCSSがhead内に出力されてしまいレンダリングをブロックしているとでてしまいます。
下記コードをfunctions.phに追加し、footerに移動させようと試みたのですがうまくいかない状況です。
この「Autoptimize」で圧縮したcssをうまくレンダリングブロックさせないいい方法はないでしょうか。
よろしくお願いいたします。
/* CSSの読み込み ---------------------------------------------------------- */ function register_stylesheet() { wp_register_style('header', get_template_directory_uri().'/header.css'); wp_register_style('sidebar', get_template_directory_uri().'/sidebar.css'); wp_register_style('footer', get_template_directory_uri().'/footer.css'); } //style.cssのみヘッダーで読み込む function add_stylesheet() { register_stylesheet(); wp_enqueue_style('header', '', array(), '1.0', false); } add_action('wp_enqueue_scripts', 'add_stylesheet'); //残りのCSSをフッターで読み込む function prefix_add_footer_styles() { wp_enqueue_style('sidebar', '', array(), '1.0', false); wp_enqueue_style('footer', '', array(), '1.0', false); }; add_action( 'wp_footer', 'prefix_add_footer_styles' );
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。