wp enqueue style - Move dashicons.min.css to Footer

Hey there WordPress community,Google page speed is moaning about dashicons.min.css being on our site. However, we need i

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745361812a4624396.html

相关推荐

  • wp enqueue style - Move dashicons.min.css to Footer

    Hey there WordPress community,Google page speed is moaning about dashicons.min.css being on our site. However, we need i

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信