[Resolved] How to disable generate-style-inline-css?

Home Forums Support [Resolved] How to disable generate-style-inline-css?

Home Forums Support How to disable generate-style-inline-css?

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1525631
    Mr 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!

    #1525834
    Elvin
    Staff
    Customer Support

    Hi,

    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/

    #1525838
    Mr Calvert

    Can 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&#8242; 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&#8242; 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&#8242; media=’all’ />
    6. <link rel=’stylesheet’ id=’generatepress-dynamic-css’ href=’//bongcuoi.com/wp-content/uploads/generatepress/style.min.css?ver=1605034639′ media=’all’ />

    #1525914
    Elvin
    Staff
    Customer Support

    Try 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.

    #1526253
    Mr Calvert

    I 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>

    #1526419
    David
    Staff
    Customer Support

    Hi 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.

    #1526530
    Mr Calvert

    I was add that css to childtheme please give me how to remove that?

    #1527072
    Leo
    Staff
    Customer Support

    You can add CSS to your child theme without removing that.

    #1527116
    Mr Calvert

    Can you give me code for remove that?

    #1527479
    Tom
    Lead Developer
    Lead Developer

    The 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.

    #2277053
    morfon

    Hi, 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.

    #2277125
    David
    Staff
    Customer Support

    Hi 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 ?

    #2277321
    morfon

    I 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.

    #2278333
    David
    Staff
    Customer Support

    Are 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

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.