• Resolved adaptablewebsites

    (@adaptablewebsites)


    Hi,
    SG Optimiser ‘Combine CSS Files’ is causing a css file of mine not to work.
    If I turn the settiing to “OFF” … the css works.
    Is there a way to get a css file to be seen by the ‘Excluide from CSS Combination” as this list cannot be added to … it is a pre-determined dropdown.
    I have tried adding the following SG Optimiser Filter in Code Snippets .. to prevent the css file from being combined. How?

    This … which does not work …

    add_filter( ‘sgo_css_combine_exclude’, ‘css_combine_exclude’ );
    function css_combine_exclude( $exclude_list ) {
    // Add the style handle to exclude list.
    $exclude_list[] = ‘https://hivefitnessbristol.co.uk/wp-content/uploads/2022/02/hivefitness-gymcatch.css’;

    return $exclude_list;
    }

    Can anyone advise me as to what I am doing wrong with the code snippet?
    Is there a way to do this in SG Optimiser directly as it has forced me to install another plugin

    Many Thanks

    Regards Mark

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support Plamen M

    (@plamenm)

    Hello @adaptablewebsites,

    The drop-down list contains CSS Styles which are added to the code of your site through standard coding procedures. CSS Styles which were added not following the standard coding recommendations, would not show up there. For these, you need to use exclusion code filters. For these, you have to find or know the handle of the style and not the style sheet name directly.

    Here is a post here which explains how you can find the handle for each one of your styles and then how to exclude it. You may also contact the developer of the theme / plugin the style of which you want to exclude and they should be able to provide you with the handle name.

    Regards,
    Plamen.M
    SiteGround Technical Support Team

    Thread Starter adaptablewebsites

    (@adaptablewebsites)

    Hi,
    Thanks for the prompt and detailed answer.
    Alas it seems there is no data handle that I can find, or that is applied, for the css style sheet I added on this page:
    https://hivefitnessbristol.co.uk/book/
    https://hivefitnessbristol.co.uk/wp-content/uploads/2022/02/hivefitness-gymcatch.css

    I have used the Identify Handle SGO Filter but no handle is associated with the above css file. Also, I have tried using the name of the file i.e. hivefitness-gymcatch as the data handle ID in the exclude list which is advised that SGO uses. This hasn’t worked either. The filter used:

    add_filter( 'sgo_css_combine_exclude', 'css_combine_exclude' );
    function css_combine_exclude( $exclude_list ) {
        // Add the style handle to exclude list.
        $exclude_list[] = 'hivefitness-gymcatch';
    
        return $exclude_list;
    }

    No luck. I have left the combine css setting on temporarily FYI

    Thanks for your help. Appreciate it.

    Regards Mark

    Plugin Support Simeon Boev

    (@k3llanved)

    Hello Mark,

    Unfortunately, without the handler, I do not think the custom snippet will be of any help. Something else you could try is to include the CSS file via Divi and then work around if content needs to be excluded or not.

    Best Regards,
    Simeon Boev

    Thread Starter adaptablewebsites

    (@adaptablewebsites)

    Simeon
    Thanks for coming back so quick … appreciate it.

    I can see the css from the css file in the SG assetts css file. As SG Optimiser has added it … should it not have provided the handler as the name part of the css file … in this case … hivefitness-gymcatch

    CSS file is: https://hivefitnessbristol.co.uk/wp-content/uploads/2022/02/hivefitness-gymcatch.css

    Am I mistaken in my thinking. Just trying to understand the problem I have and how I may solve effectively in the long-term

    Thanks

    Regards Mark

    Plugin Support Delyan Delov

    (@delyandelov)

    Hello Mark,

    The handle does not always match the file name. We can help you find the proper handle if you provide us with the exact page where the CSS file should be loaded as we need to trigger the CSS code execution.

    Regards,
    Delyan Delov

    Thread Starter adaptablewebsites

    (@adaptablewebsites)

    Delyan,

    Thanks for clarifying this.

    The page in question: https://hivefitnessbristol.co.uk/book

    The CSS loaded is:

    <link rel=”stylesheet” href=”https://hivefitnessbristol.co.uk/wp-content/uploads/2022/02/hivefitness-gymcatch.css”&gt;

    Combine CSS Files is off in SGO

    Many Thanks

    Regards Mark

    Plugin Support Delyan Delov

    (@delyandelov)

    I have examined your site and it seems that the file in question is not included properly as its code is not loaded on the site.

    Please revise your CSS implementation and make sure the file is correctly included and loaded on the site.

    Regards,
    Delyan Delov

    Thread Starter adaptablewebsites

    (@adaptablewebsites)

    Delyan,

    This: https://hivefitnessbristol.co.uk/book/

    View Page Source … shows this:

    <link rel=”stylesheet” href=”https://hivefitnessbristol.co.uk/wp-content/uploads/2022/02/hivefitness-gymcatch.css”&gt;

    Browsers show a change from the stylesheet i.e. calendar function etc shows the green of the brand which is being implemented by the stylesheet.

    Would you be kind enough to check again .. doesn’t make a lot of sense.

    Many Thanks, Mark

    Plugin Support Pavel Dosev

    (@pdosev)

    Hello Mark,

    I checked the site, and the issue probably comes from the way the stylesheet is included on the page.

    <link rel="stylesheet" href="https://hivefitnessbristol.co.uk/wp-content/uploads/2022/02/hivefitness-gymcatch.css">

    In their documentation (p.4 below) they specify that the CSS can be included there however it needs to be wrapped in <style></style> tags:

    https://www.divithemeexamples.com/add-custom-css-to-divi/

    Please try using one of the methods described in their documentation and it should be working correctly.

    • This reply was modified 4 years, 4 months ago by Pavel Dosev.
    • This reply was modified 4 years, 4 months ago by Pavel Dosev.

    Hello,

    Other minifying plugins, for example WP Fastest Cache – offer an option to add a filter that searches for strings in the JS or CSS and exclude. This works whether or not the CSS or JS was added properly in WordPress or not. Could you include this in future updates? Right now a number of sites I’d prefer to use SG optimizer, but I have to use WP Fastest Cache instead because I can’t exclude CSS / JS, and WPFC doesn’t play well with your server’s cache settings so it’s a big headache.

    Plugin Support Delyan Delov

    (@delyandelov)

    I will pass your suggestion to our developers so they can consider such functionality for future releases.

    Best Regards,
    Delyan Delov

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘How To Exclude CSS File From SG Optimiser Combine CSS’ is closed to new replies.