CSS aggregation and performance – custom CSS broken after enabling

Today I turned on the CSS aggregation feature in Performance and promptly broke all of my custom CSS. well, almost all of it. It was apparently pretty quickly that the custom css that i have in my custom css file was missing. the css file is properly registered in the .info file so at first I wasn’t sure what the problem was. then i found this.

https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add_css/7

If CSS aggregation/compression is enabled, all cascading style sheets added with $options[‘preprocess’] set to TRUE will be merged into one aggregate file and compressed by removing all extraneous white space.

so the workaround is to add all the custom css to a file that has had this variable set to TRUE. any of the subthemed css files that you may have moved will do. CSS doesn’t really care what file the styles come from; it just cares what they affect. the real fix will be to get the variable to be set to true for my custom file.

BTW, the performance difference is really noticeable: you have to be able to turn this on.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: