Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1420731

    xthemer
    Participant

    x theme puts my global CSS in the head of every page on my site, instead of moving it to an external file (<style id=”x-generated-css” type=”text/css”>).

    While developing my site late last year, I asked x theme support if having the code there impacts performance. The answer I got was no.

    Quite a few other posts I have since read indicate that having the CSS in the head is indeed a performance issue, particularly from a SEO perspective. It shouldn’t be there at all.

    I’d like this block of code out of there.

    Simply moving the global CSS to my child stylesheet doesn’t work.

    I’ve also tried the following suggested changes to the functions file, which doesn’t work:

    function remove_inline_customizer_css () {
    remove_action( ‘wp_head’, ‘x_customizer_generated_css_output’, 9998);
    }
    add_action(‘after_setup_theme’, ‘remove_inline_customizer_css’);

    Finally, I’ve tried the following two suggestions from Rad, both of which don’t work for me, either because nothing happens or my design breaks site wide:

    1) function x_output_generated_styles() {
    //Empty
    }

    2) function x_enqueue_site_styles() {

    //
    // Stack data.
    //

    $stack = x_get_stack();
    $design = x_get_option( ‘x_integrity_design’ );

    if ( $stack == ‘integrity’ && $design == ‘light’ ) {
    $ext = ‘-light’;
    } elseif ( $stack == ‘integrity’ && $design == ‘dark’ ) {
    $ext = ‘-dark’;
    } else {
    $ext = ”;
    }

    //
    // Register styles.
    //

    wp_register_style( ‘x-stack’, X_TEMPLATE_URL . ‘/framework/css/dist/site/stacks/’ . $stack . $ext . ‘.css’, NULL, X_VERSION, ‘all’ );
    wp_enqueue_style( ‘x-stack’ );

    //
    // Enqueue styles.
    //

    wp_enqueue_style( ‘x-child’, get_stylesheet_directory_uri() . ‘/style.css’, array() , X_VERSION, ‘all’ );
    wp_enqueue_style( ‘x-child-global’, get_stylesheet_directory_uri() . ‘/global-style.css’, array() , X_VERSION, ‘all’ );

    if ( is_rtl() ) {
    wp_enqueue_style( ‘x-rtl’, X_TEMPLATE_URL . ‘/framework/css/dist/site/rtl/’ . $stack . ‘.css’, NULL, X_VERSION, ‘all’ );
    }

    if ( X_BBPRESS_IS_ACTIVE ) {
    if ( x_is_bbpress() ) {
    wp_deregister_style( ‘buttons’ );
    }
    wp_deregister_style( ‘bbp-default’ );
    wp_enqueue_style( ‘x-bbpress’, X_TEMPLATE_URL . ‘/framework/css/dist/site/bbpress/’ . $stack . $ext . ‘.css’, NULL, X_VERSION, ‘all’ );
    }

    if ( X_BUDDYPRESS_IS_ACTIVE ) {
    wp_deregister_style( ‘bp-legacy-css’ );
    wp_deregister_style( ‘bp-admin-bar’ );
    wp_enqueue_style( ‘x-buddypress’, X_TEMPLATE_URL . ‘/framework/css/dist/site/buddypress/’ . $stack . $ext . ‘.css’, NULL, X_VERSION, ‘all’ );
    }

    if ( X_WOOCOMMERCE_IS_ACTIVE ) {
    wp_deregister_style( ‘woocommerce-layout’ );
    wp_deregister_style( ‘woocommerce-general’ );
    wp_deregister_style( ‘woocommerce-smallscreen’ );
    wp_enqueue_style( ‘x-woocommerce’, X_TEMPLATE_URL . ‘/framework/css/dist/site/woocommerce/’ . $stack . $ext . ‘.css’, NULL, X_VERSION, ‘all’ );
    }

    if ( X_GRAVITY_FORMS_IS_ACTIVE ) {
    wp_enqueue_style( ‘x-gravity-forms’, X_TEMPLATE_URL . ‘/framework/css/dist/site/gravity_forms/’ . $stack . $ext . ‘.css’, NULL, X_VERSION, ‘all’ );
    }

    if ( X_CONTACT_FORM_7_IS_ACTIVE ) {
    wp_deregister_style( ‘contact-form-7’ );
    }

    x_enqueue_google_fonts();

    }

    How can I remove the global CSS from the head without wrecking the entire design of my entire site?

    Thanks for your help.

    #1421114

    Rad
    Moderator

    Hi there,

    Thanks for posting in.

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    I like to test it directly from the code, and please provide the thread where the code is provided.

    Thanks!

    #1421495

    xthemer
    Participant
    This reply has been marked as private.
    #1422073

    xthemer
    Participant
    This reply has been marked as private.
    #1422463

    Lely
    Moderator

    Hello There,

    This code will only work if you have copied the output CSS code on the header on your child theme first.

    function x_output_generated_styles() {
     //Empty
    }

    So the process is, you move the generated CSS from the customizer, it’s the CSS on the header part and then add the code. It is not recommended though because you cannot use customizer anymore. It will stop how customizer dynamic function works.

    Check detailed explanation here:https://community.theme.co/forums/topic/request-move-customizer-css-to-custom-file/#post-741669

    #1422727

    xthemer
    Participant

    Hi Lely,

    I had tried that twice already. And just now a third time. But the process breaks my design. I’ll send a screen shot.

    Rad asked for my login credentials, which I provided. So I kind of got the impression you planned to take a look at what’s happening onsite. It would be great if you could. Thanks.

    #1422728

    xthemer
    Participant
    This reply has been marked as private.
    #1422738

    xthemer
    Participant

    Hey there,

    The issue seems to have been the caching effect. After purging W3 Total Cache caches again, everything seems to be working now. So my mistake and problem solved. Thanks for your support.

    #1423056

    Jade
    Moderator

    Glad to hear it’s sorted.

    Cheers!