Assets Optimization messing CSS

When I enable the Assets Optimization, the bootstrap.min.css loads after my style.css making my codes be replaced and messing my layout, can you help me?

  • Pawel

    Hello Sarah!

    I hope you're well today and thank you for reaching out to us!

    I tried multiple approaches to test this and see if I can make the CSS be included in the correct order. I've added a dependency declaration to your theme's functions.php, so now the appropriate lines read:

    wp_enqueue_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css');
    wp_enqueue_style( 'sffallshow-style', get_stylesheet_uri(), array('bootstrap') );

    In WordPress it's usually not enough to just enqueue scripts in the right order, if there are dependencies between them, they have to be explicitly added (hence the array( 'bootstrap' ) addition on the second line). This unfortunately didn't fix the issue.

    It is generally difficult to manage the order of stylesheets in WordPress, especially if there are multiple plugins with their own custom styles present. This is why we put a message when you activate Asset Optimisation that there may be situations where this option is not suitable.

    I've also tested this on my local test site - using your theme and a minimal set of plugins (WP-SCSS and Advanced Custom Fields). This also resulted in the same issue on my site.

    I disabled Asset Optimisation on your website for now. I've also asked our support team for some feedback on what else can be done here, and I'm waiting for the Hummingbird developers to reply to my question (it's Sunday, so they will probably be available tomorrow). I've set up a reminder for tomorrow so I remeber to come back to your ticket and I'll reply again as soon as I get any feedback from the lead developer of Hummingbird.

    Kind regards,
    Pawel

  • Pawel

    Hello Sarah!

    I hope you're well today!

    I'm very sorry for any inconvenience this may have caused you. The popup with the warning appears only when the functionality is activated, so I assume that's what happened - fortunately this is simply reversible by disabling the feature (none of the files are modified in the process). Asset optimisation is a tricky thing, as the popup says - and some sites don't support it without at least some custom coding, for example - to make them compatible. It very much depends on the installed plugins and theme and if they follow WordPress guidelines exactly, especially using the appropriate methods for scripting and CSS styling.

    I'll ask our Second Line Support team to take a look, maybe they will be able to come up with a solution. There's no guarantee, though. It may be that custom coding is necessary to fix this.

    Kind regards,
    Pawel

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.