最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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/

发布评论

评论列表(0)

  1. 暂无评论