Archived topic
State the best way to completely remove generate-style-inline-css
7 replies · Started by David on November 19, 2017
Thanks.
In GP version prior to 2.0:
add_action( 'after_setup_theme', 'tu_remove_dynamic_css' );
function tu_remove_dynamic_css() {
remove_action( 'wp_enqueue_scripts', 'generate_color_scripts', 50 );
remove_action( 'wp_enqueue_scripts', 'generate_spacing_scripts', 50 );
remove_action( 'wp_enqueue_scripts', 'generate_typography_scripts', 50 );
remove_action( 'wp_enqueue_scripts', 'generate_secondary_color_scripts', 80 );
remove_action( 'wp_enqueue_scripts', 'generate_background_scripts', 70 );
}
In GP 2.0:
add_action( 'after_setup_theme', 'tu_remove_dynamic_css' );
function tu_remove_dynamic_css() {
remove_action( 'wp_enqueue_scripts', 'generate_enqueue_dynamic_css', 50 );
}
Thanks!
No problem :)
Hi!
Have you noticed that still remains some stuff?
<style id='generate-style-inline-css' type='text/css'>
.main-navigation .navigation-logo img {height:60px;}@media (max-width: 1030px) {.main-navigation .navigation-logo.site-logo {margin-left:0;}body.sticky-menu-logo.nav-float-left .main-navigation .site-logo.navigation-logo {margin-right:0;}}.mobile-header-navigation .mobile-header-logo img {height:60px;}.main-navigation .main-nav ul li a,.menu-toggle,.main-navigation .mobile-bar-items a{transition: line-height 300ms ease}
.slideout-navigation.main-navigation .main-nav ul li a{font-weight:normal;text-transform:none;}
</style>
Ah, that's coming from the Menu Plus module and can't be removed as easily.
Another idea is to remove the core stylesheet in GP, and re-add it with a different ID:
add_action( 'wp_enqueue_scripts', 'tu_rename_style', 20 );
function tu_rename_style() {
wp_dequeue_style( 'generate-style' );
wp_enqueue_style( 'generate-custom-style', get_template_directory_uri() . "/style.min.css", array( 'generate-style-grid' ), GENERATE_VERSION, 'all' );
}
does not remove inline CSS :/
Can you link me to your site?
BTW, I definitely don't suggest that anyone do this. It will make it so all of the Customizer settings no longer work.
If you don't want inline CSS, I suggest using Autoptimize (https://wordpress.org/plugins/autoptimize/). It takes all of the inline CSS and caches it inside a file.