functions.phpに追記する
CSS
/*--------------------------------------------------------------*/ /* レンダリングを妨げるリソースの除外 CSSのIDを遅延させる処理 */ /*--------------------------------------------------------------*/ function my_dequeue_plugin_files(){ wp_dequeue_style('crayon'); wp_dequeue_style('crayon-theme-neon'); wp_dequeue_style('crayon-font-monaco'); wp_dequeue_style('contact-form-7'); wp_dequeue_style('pz-linkcard'); wp_dequeue_style('responsive-lightbox-nivo'); wp_dequeue_style('responsive-lightbox-nivo-default'); } add_action( 'wp_enqueue_scripts', 'my_dequeue_plugin_files', 9999); add_action('wp_head', 'my_dequeue_plugin_files', 9999); function my_enqueue_plugin_files(){ wp_enqueue_style('crayon'); wp_enqueue_style('crayon-theme-neon'); wp_enqueue_style('crayon-font-monaco'); wp_enqueue_style('contact-form-7'); wp_enqueue_style('pz-linkcard'); wp_enqueue_style('responsive-lightbox-nivo'); wp_enqueue_style('responsive-lightbox-nivo-default'); } add_action('wp_footer', 'my_enqueue_plugin_files'); /*-----------------------------------------------------------------*/
JS
/*-----------------------------------------------------------------*/ /* レンダリングを妨げるリソースの除外 JSファイルを遅延させる処理 */ /*-----------------------------------------------------------------*/ 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'); } /*--------------------------------------------------------------*/