Viewing 1 replies (of 1 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi,

    Unfortunately there is no option for that. Usually minify/cache plugins are used to remove the stylesheets.

    With a custom code it might be possible, but please be careful. Add this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    function asl_remove_styles() {
        global $wp_filter;
        if ( isset($wp_filter['wp_head'], $wp_filter['wp_head']->callbacks, $wp_filter['wp_head']->callbacks[10]) ) {
            foreach ( $wp_filter['wp_head']->callbacks[10] as $k => &$f ) {
                if (
                    isset($f['function']) &&
                    is_array($f['function']) &&
                    isset($f['function'][1])
                ) {
                    if ( in_array($f['function'][1], array('StyleSheets', 'handle', 'inlineCSS')) ) {
                        unset($wp_filter['wp_head']->callbacks[10][$k]);
                    }
                }
            }
        }
    
        if ( isset($wp_filter['wp_enqueue_scripts'], $wp_filter['wp_enqueue_scripts']->callbacks, $wp_filter['wp_enqueue_scripts']->callbacks[10]) ) {
            foreach ( $wp_filter['wp_enqueue_scripts']->callbacks[10] as $k => &$f ) {
                if (
                    isset($f['function']) &&
                    is_array($f['function']) &&
                    isset($f['function'][1])
                ) {
                    if ( in_array($f['function'][1], array('StyleSheets', 'handle', 'inlineCSS')) ) {
                        unset($wp_filter['wp_enqueue_scripts']->callbacks[10][$k]);
                    }
                }
            }
        }
    }
    add_action( 'wp_head', 'asl_remove_styles', 100 );
    add_action( 'wp_enqueue_scripts', 'asl_remove_styles', 100 );
    add_action( 'init', 'asl_remove_styles' );

    Best,
    Ernest M.

Viewing 1 replies (of 1 total)

The topic ‘Remove CSS from head’ is closed to new replies.