Remove injected CSS (styles in site head)

Knowledgebase Docs » UberMenu 3
USEFUL? 6
UberMenu 3

Please be aware if you disable this, you will disable plugin functionality such as the Customizer, Menu Item Custom Style Settings, Custom CSS Tweaks, etc.

By default, when you use the Customizer or add custom CSS styles through the Control Panel, they will be printed in your site’s <head>. If you would like to remove these styles, you can do so by unhooking the UberMenu injection function. Just add this PHP to your child theme’s functions.php

function um_remove_custom_css(){
	remove_action( 'wp_head' , 'ubermenu_inject_custom_css' );
}
add_action( 'wp_head' , 'um_remove_custom_css' , 1 );

Of course, if you remove this action, none of the custom style settings (Customizer, Menu Item Custom Style settings, Custom CSS Tweaks) will work any longer. Any CSS that was previously inserted there should be copied into another stylesheet. Remember that no matter where you put the code, it’ll need to come AFTER the UberMenu stylesheets in order to function properly. The order is very important and taking this out of UberMenu’s control means you need to manage it properly.

A better solution is to use Autoptimize, which will remove the code from the head and combine it into minified stylesheets with the rest of your CSS. This allows you to continue using the built in dynamic style settings while automatically extracting the code from the site head.