Home / Admin / Dequeue CSS files conditionally
Duplicate Snippet

Embed Snippet on Your Site

Dequeue CSS files conditionally

Dequeue CSS files conditionally

Code Preview
php
<?php
function remove_unused_css() {
    // Check if it's not the homepage or not a specific post type
    if ( !is_front_page() && !is_page('your-page-slug') ) {
        wp_dequeue_style('unused-stylesheet-handle');
        wp_deregister_style('unused-stylesheet-handle');
    }
}
add_action('wp_enqueue_scripts', 'remove_unused_css');

Comments

Add a Comment