- This topic has 13 replies, 6 voices, and was last updated 1 year, 8 months ago by David.
-
AuthorPosts
-
November 10, 2020 at 8:57 am #1525631Mr Calvert
Hello I have one question please help me!
I see one style is <style id=’generate-style-inline-css’> in <head> how to remove that? I not want show css inline. I need at that to child theme!November 10, 2020 at 11:45 am #1525834ElvinStaffCustomer SupportHi,
You can try adding this PHP snippet:
add_action( 'wp_enqueue_scripts', 'generate_replace_inline_css', 100 ); function generate_replace_inline_css() { wp_dequeue_style( 'generate-style' ); }
Here’s how to add PHP – https://docs.generatepress.com/article/adding-php/
November 10, 2020 at 11:58 am #1525838Mr CalvertCan you guide for me disable one by one all this? I not want disable all I only want code to disable one to one for test!
1. <link rel=’stylesheet’ id=’generate-fonts-css’ href=’//fonts.googleapis.com/css?family=Oxygen:300,regular,700′ media=’all’ />
2. <link rel=’stylesheet’ id=’wp-block-library-css’ href=’https://bongcuoi.com/wp-includes/css/dist/block-library/style.min.css?ver=5.5.3′ media=’all’ />
3. <link rel=’stylesheet’ id=’generateblocks-css’ href=’//bongcuoi.com/wp-content/uploads/generateblocks/style-123.css?ver=1604717855′ media=’all’ />
4. <link rel=’stylesheet’ id=’generate-widget-areas-css’ href=’https://bongcuoi.com/wp-content/themes/generatepress/assets/css/components/widget-areas.min.css?ver=3.0.2′ media=’all’ />
5. <link rel=’stylesheet’ id=’generate-style-css’ href=’https://bongcuoi.com/wp-content/themes/generatepress/assets/css/main.min.css?ver=3.0.2′ media=’all’ />
6. <link rel=’stylesheet’ id=’generatepress-dynamic-css’ href=’//bongcuoi.com/wp-content/uploads/generatepress/style.min.css?ver=1605034639′ media=’all’ />November 10, 2020 at 1:40 pm #1525914ElvinStaffCustomer SupportTry these:
add_action( 'wp_enqueue_scripts', 'generate_replace_inline_css', 100 ); function generate_replace_inline_css() { wp_dequeue_style( 'generate-fonts' ); wp_dequeue_style( 'wp-block-library' ); wp_dequeue_style( 'generate-widget-areas' ); wp_dequeue_style( 'generateblocks' ); wp_dequeue_style( 'generate-style' ); wp_dequeue_style( 'generatepress-dynamic' ); }
I don’t recommend removing wp-block-library & generateblocks as it is used by Gutenberg editor.
November 10, 2020 at 10:13 pm #1526253Mr CalvertI was try add but it not remove sir.
https://bongcuoi.com
Please check for me! I was add this code:
add_action( ‘wp_enqueue_scripts’, ‘generate_replace_inline_css’, 100 );
function generate_replace_inline_css() {
wp_dequeue_style( ‘generate-style’ );
}But when Ctrl+U I was see that exitent:
<style id=’generate-style-inline-css’>
.is-right-sidebar{width:30%;}.is-left-sidebar{width:30%;}.site-content .content-area{width:100%;}@media (max-width:768px){.main-navigation .menu-toggle,.sidebar-nav-mobile:not(#sticky-placeholder){display:block;}.main-navigation ul,.gen-sidebar-nav,.main-navigation:not(.slideout-navigation):not(.toggled) .main-nav > ul,.has-inline-mobile-toggle #site-navigation .inside-navigation > *:not(.navigation-search):not(.main-nav){display:none;}.nav-align-right .inside-navigation,.nav-align-center .inside-navigation{justify-content:space-between;}.has-inline-mobile-toggle .mobile-menu-control-wrapper{display:flex;flex-wrap:wrap;}.has-inline-mobile-toggle .inside-header{flex-direction:row;text-align:left;flex-wrap:wrap;}.has-inline-mobile-toggle .header-widget,.has-inline-mobile-toggle #site-navigation{flex-basis:100%;}.nav-float-left .has-inline-mobile-toggle #site-navigation{order:10;}}
</style>November 11, 2020 at 2:25 am #1526419DavidStaffCustomer SupportHi there,
why do you want to remove the
generate-style-inline-css
? This is required by the theme to display the content correctly. Without it some elements will not be styled correctly.November 11, 2020 at 4:31 am #1526530Mr CalvertI was add that css to childtheme please give me how to remove that?
November 11, 2020 at 8:37 am #1527072LeoStaffCustomer SupportYou can add CSS to your child theme without removing that.
November 11, 2020 at 8:59 am #1527116Mr CalvertCan you give me code for remove that?
November 11, 2020 at 2:24 pm #1527479TomLead DeveloperLead DeveloperThe code that Elvin shared should do it: https://generatepress.com/forums/topic/how-to-disable-generate-style-inline-css/#post-1525914
However, it’s not a good idea – I don’t recommend doing this.
What’s the difference between adding that CSS to your child theme vs. using the External File option in “Customize > General”. The latter will make it so you can continue to customize the theme without running into issues, and it will give you the same results that adding the CSS to your child theme will.
July 8, 2022 at 4:53 am #2277053morfonHi, I’m late to the party but am facing the same issue. I hope it’s ok to reanimate an old thread.
None of the solutions posted above disable the inline css. I’ve tried them both in my functions.php in the child theme. No banana.
To answer David’s question of why remove the inline css, there are people out there, even if a dying breed, who want to control the appearance of their sites exclusively through css manually and not through WP admin. I absolutely never use any gutenberg or block editor, I avoid it like plague. I understand why WP chose to go the full site editing path, but it doesn’t concern me. My first priority is performance, and the only reason I chose GP is because it allows me to build fast and lightweight business websites, without overhead junk in code. I also often use AMP which only allows a single inline css to be used, and its size is limited. I use it in combination with Hummingbird that puts everything into a single css, although this will contain plenty of contradicting and excess rules that greatly increase the size.
Whenever you build your child theme you need to find the styles in the inline css that messes up your design and then add a declaration that overrules it. This is not just ridiculous but an extremely ineffective and time consuming process. Just an example, I’m right now building a dark theme and some divs have white background that don’t respond to a generic rule, e.g. if you set all div or aside background to transparent. You need to select them individually.
So I’d like to disable all inline css entirely. Please post a solution compatible with WP6 that works. In fact, it would be awesome to have a toggle in admin, at least in GP Premium, to do just that. Thanks in advance.
July 8, 2022 at 6:47 am #2277125DavidStaffCustomer SupportHi there,
Elvins code here:
https://generatepress.com/forums/topic/how-to-disable-generate-style-inline-css/#post-1525914
i tried it on a WP 6.0 test install and it removed those styles it lists.? What part isn’t working ?
July 8, 2022 at 9:09 am #2277321morfonI tried that, it does absolutely nothing. I still have global-styles-inline and generate-style-inline in the code.
I also tried the previous version posted in #1525834. It removes one thing: wp-block-library-css.Update:
I see the two snippets are identical, the second one is just extended, so this behavior doesn’t make sense, but still this is the case. On multiple attempts the result is the same: wp-block-library on or off. Nothing else is affected unfortunately.July 10, 2022 at 2:33 am #2278333DavidStaffCustomer SupportAre you using any other functions? As Elvins code is working fore me on 3 test sites. Can’t see what would stop that from working?
The
global-styles-inline
is a core stylesheet. See here for the code to remove those:https://github.com/WordPress/gutenberg/issues/36834#issuecomment-1048923664
-
AuthorPosts
- You must be logged in to reply to this topic.