theme development - Dequeue a style file which is making website load slow!

I have a website running on GrandNews WordPress Theme () and loading via KeyCDN. The site is loading a CSS file located

I have a website running on GrandNews WordPress Theme () and loading via KeyCDN. The site is loading a CSS file located at websitedomain.kxcdn/wp-content/themes/grandnews/modules/kirki/assets/css/kirki-styles.css which is of 0KB size and not in use. This file "kirki-styles.css" is making website load slow as you can see here: and CDN support suggested me to dequeue the stylesheet in a child theme functions.php file which I tried to but somehow it's not working and server still try to load file and gives 504 error.

Maybe something wrong with my code. So far I have followed these steps:

  1. Created a Child Theme and tested it... It's working.
  2. Tried following pieces of code to try to make it to work (Nothing extra)

     add_action('wp_enqueue_scripts', 'kirki_style_remove', 100);
        function kirki_style_remove()
        {
            wp_dequeue_style('/wp-content/themes/grandnews/modules/kirki/assets/css/kirki-styles.css');
        }
    

    Tried this way once as well:

    function wp_dequeue_kirki_style()
    {
        wp_dequeue_style('kirki-styles', 'websitedomain.kxcdn/wp-content/themes/grandnews/modules/kirki/assets/css/kirki-styles.css');
        // wp_deregister_style('kirki-styles');
    }
    add_action('wp_enqueue_scripts', 'wp_dequeue_kirki_style', '999');
    

Apart from these two codes above, I also tried a plugin but that didn't work as well.

Please advise with the most efficient solution. Thanks in advance!

I have a website running on GrandNews WordPress Theme (https://themeforest/item/grand-news-news-magazine/15885465) and loading via KeyCDN. The site is loading a CSS file located at websitedomain.kxcdn/wp-content/themes/grandnews/modules/kirki/assets/css/kirki-styles.css which is of 0KB size and not in use. This file "kirki-styles.css" is making website load slow as you can see here: http://prntscr/qoho6e and CDN support suggested me to dequeue the stylesheet in a child theme functions.php file which I tried to but somehow it's not working and server still try to load file and gives 504 error.

Maybe something wrong with my code. So far I have followed these steps:

  1. Created a Child Theme and tested it... It's working.
  2. Tried following pieces of code to try to make it to work (Nothing extra)

     add_action('wp_enqueue_scripts', 'kirki_style_remove', 100);
        function kirki_style_remove()
        {
            wp_dequeue_style('/wp-content/themes/grandnews/modules/kirki/assets/css/kirki-styles.css');
        }
    

    Tried this way once as well:

    function wp_dequeue_kirki_style()
    {
        wp_dequeue_style('kirki-styles', 'websitedomain.kxcdn/wp-content/themes/grandnews/modules/kirki/assets/css/kirki-styles.css');
        // wp_deregister_style('kirki-styles');
    }
    add_action('wp_enqueue_scripts', 'wp_dequeue_kirki_style', '999');
    

Apart from these two codes above, I also tried a plugin but that didn't work as well.

Please advise with the most efficient solution. Thanks in advance!

Share Improve this question edited Jan 16, 2020 at 11:30 Tejas Gajjar 4802 silver badges9 bronze badges asked Jan 16, 2020 at 11:25 SherylSheryl 428 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3
function wp_dequeue_kirki_style()
{

    wp_dequeue_style('kirki-styles');
}
add_action('wp_enqueue_scripts', 'wp_dequeue_kirki_style');

Please make sure that you have handler name kirki-styles in the parent theme for the css file that you want to remove. Because wp_dequeue_style function used handler as parameter. You can check documentaion of dequeue function here => https://developer.wordpress/reference/functions/wp_dequeue_style/

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

相关推荐

  • theme development - Dequeue a style file which is making website load slow!

    I have a website running on GrandNews WordPress Theme () and loading via KeyCDN. The site is loading a CSS file located

    10小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信