Title: Autoptimize breaks CSS
Last modified: February 13, 2018

---

# Autoptimize breaks CSS

 *  Resolved [luiscmas](https://wordpress.org/support/users/luiscmas/)
 * (@luiscmas)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/autoptimize-breaks-css-2/)
 * 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](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fautoptimize-breaks-css-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/autoptimize-breaks-css-2/#post-9968759)
 * 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](https://wordpress.org/support/users/luiscmas/)
 * (@luiscmas)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/autoptimize-breaks-css-2/#post-9969016)
 * 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/](http://mvets.aititubi.es/)
   view-source:[http://mvets.aititubi.es/?ao_noptimize=1](http://mvets.aititubi.es/?ao_noptimize=1)
 * Which could be the reason for the behaviour change?
 * Thanks in advance!!!
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/autoptimize-breaks-css-2/#post-9969108)
 * > 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](https://wordpress.org/support/users/luiscmas/)
 * (@luiscmas)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/autoptimize-breaks-css-2/#post-9969174)
 * 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.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [luiscmas](https://wordpress.org/support/users/luiscmas/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/autoptimize-breaks-css-2/#post-9969174)
 * Status: resolved