admin管理员组

文章数量:1425747

Hey there WordPress community,

Google page speed is moaning about dashicons.min.css being on our site. However, we need it for the Mega menu.

I wanted to know if it's possible to move it to the footer.

I have tried this code already:

add_action( 'wp_print_styles', 'my_deregister_styles' );
function my_deregister_styles()    { 
   wp_deregister_style( 'dashicons' ); 
   wp_enqueue_style( 'dashicons', array(), false, true );
}

I have also tried a few other samples, however, nothing seems to work here.

Any ideas?

Thanks

Hey there WordPress community,

Google page speed is moaning about dashicons.min.css being on our site. However, we need it for the Mega menu.

I wanted to know if it's possible to move it to the footer.

I have tried this code already:

add_action( 'wp_print_styles', 'my_deregister_styles' );
function my_deregister_styles()    { 
   wp_deregister_style( 'dashicons' ); 
   wp_enqueue_style( 'dashicons', array(), false, true );
}

I have also tried a few other samples, however, nothing seems to work here.

Any ideas?

Thanks

Share Improve this question asked Jun 28, 2019 at 10:13 ChrisChris 234 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

Please try below code :

add_action( 'wp_print_styles', 'my_deregister_styles' );
function my_deregister_styles()    { 
   wp_deregister_style( 'dashicons' ); 
}

Replace your css path "PATH_OF_CSS" :

add_action( 'wp_footer', 'register_wp_footer', 11 );
function register_wp_footer() { 
    wp_enqueue_style( 'dashicons', 'PATH_OF_CSS' ,array(), false, true );
}

Final working solution was:

add_action( 'wp_print_styles', 'my_deregister_styles' );
function my_deregister_styles()    { 
   wp_deregister_style( 'dashicons' ); 
}

add_action( 'wp_footer', 'register_wp_footer' );
function register_wp_footer() { 
    wp_enqueue_style( 'dashicons', '/wp-includes/css/dashicons.min.css');
}

本文标签: wp enqueue styleMove dashiconsmincss to Footer