Does anyone know if it's possible to deregister the default stylesheet of a theme, style.css, in WordPress? I've tried going wp_deregister_style('style') and wp_deregister_style('style.css'), but neither seems to work.
I'm hoping to do this so I can optimise my site my combining my various stylesheets into one and minifying it with an Ant script.
WordPress includes 2 functions which you can use in your child themes functions. php file to deregister and dequeue style sheets for themes and plugins. Deregister a CSS file that was registered with wp_register_style(). Dequeue a CSS file that was enqueued with wp_enqueue_style().
On the post edit screen, you'll find the Asset CleanUp box just below the post editor. The plugin will automatically fetch and list all the files and assets loaded when a visitor views this page on your website. You can then simply unload the unused CSS or JavaScript files that you don't need on that page.
Easiest: use the Customizer Clicking on the Customize menu link will take you to the Customizer panel. The CSS editor can be found under the Additional CSS panel. The CSS editor is essentially a mini code editor for you to add your own custom CSS: The CSS editor in the WordPress Customizer.
According to Wordpress behavior, which requires to pass a handle when registering and de-registering a stylesheet, and as the default stylesheet "style.css" is registered with the handle "screen", we should use this code :
wp_dequeue_style('screen');
wp_deregister_style('screen');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With