• Resolved luiscmas

    (@luiscmas)


    Hello,

    We are facing problems with CSS and Autoptimize.

    When we activate Autoptimize, the optimized CSS is loading at the top of the page and before the /wp-content/themes/bridge/css/style_dynamic.php of the theme, but when the plugin is not activated the order is different and they get loaded after (line 98 contains style_dynamic.php and line 103 contains child theme’s stylesheet).

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    AO by default injects the autoptimized CSS before the title-tag, but you can force AO to do otherwise by hooking into the API, e.g. this small code snippet which lets AO inject before the closing head-tag;

    add_filter('autoptimize_filter_css_replacetag','luicscmas_css_replacetag',10,1);
    function luicscmas_css_replacetag($replacetag) {
    	return array("</head>","before");
    	}

    the first element of the array is the HTML-tag to look for, the second one is one of “before”, “after” or “replace”.

    hope this helps,
    frank

    Thread Starter luiscmas

    (@luiscmas)

    Thanks!!!

    I’ll give it a try.

    I checked a prior version of the theme and WordPress and the /wp-content/themes/bridge/css/style_dynamic.php was “removed” from optimized version:

    WordPress 4.8.4 and old version of theme (BridgeVersión 11.0)
    view-source:http://mvets.aititubi.es/
    view-source:http://mvets.aititubi.es/?ao_noptimize=1

    Which could be the reason for the behaviour change?

    Thanks in advance!!!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I checked a prior version of the theme and WordPress and the /wp-content/themes/bridge/css/style_dynamic.php was “removed” from optimized version:

    AO never aggregates/ optimizes CSS (or JS) that is served through PHP, but when looking at the un-optimized HTML source, these are not dynamic PHP but static CSS files:

    
    <link rel='stylesheet' id='style_dynamic-css'  href='http://mvets.aititubi.es/wp-content/themes/bridge/css/style_dynamic.css?ver=1515497301' type='text/css' media='all' />

    As such they are removed (as in aggregated & optimized) by AO.

    frank

    Thread Starter luiscmas

    (@luiscmas)

    Ok thanks, so that’s why changed the behavior… in the prior version, it was a style_dynamic.css and now it’s a style_dynamic.php…

    I’ll contact the Theme Authors then!

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Autoptimize breaks CSS’ is closed to new replies.