0

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

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 );
}
1
  • Thanks for the answer. It was very close. I just had to remove: ",array(), false, true". – Chris Jun 28 '19 at 12:59
0

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');
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.