How do I dequeue a parent theme’s CSS file?

I want to use @import instead so I can override styles more easily

Simply. Don’t. Do. That.

You simply jump into the same hook and then deregister/dequeue the styles/scripts and throw in your custom ones.

function PREFIX_remove_scripts() {
    wp_dequeue_style( 'screen' );
    wp_deregister_style( 'screen' );

    wp_dequeue_script( 'site' );
    wp_deregister_script( 'site' );

    // Now register your styles and scripts here
}
add_action( 'wp_enqueue_scripts', 'PREFIX_remove_scripts', 20 );

The reason for dequeue-ing and deregistering the scripts is simple:

Note that if you’d like to be able to use either of those handles ('screen' or 'site') after dequeuing them, you’ll need to deregister them too. For instance: wp_deregister_style( 'screen' ); and wp_deregister_script( 'site' );peterjmag

Leave a Comment

error code: 523