I know that Drupal 7 has settings for Aggregate and compress CSS files and Aggregate Jacascript files (under Administration/Configuration/Development/Performance).

Is there a tool that let me extract the result of this process?

I am using Sass and Compass, so I guess that to produce an aggregate and compressed .css, I could set output_style = :compressed in Compass and the just concatenate together all the separate .css files, but that won't resolve conflicts or combine overlapping CSS selectors.

I wonder if there are some better way to do this, for instance making use of the Drupal built-in tool that apperently is designed specifically for the job.

This is for a Zen sub-theme. The Zen STARTERKIT produces a lot of CSS-files, and before making this sub-theme generally available, I would like to "clean up" the distribution by consolidating CSS and Javascript into two aggregate and compact files.

(Outside the Drupal universe, YUI compressor seems to be the most popular tool for this.)

  • If you are looking for tool independent from Drupal, it's not a Drupal question.
    – Mołot
    May 20, 2013 at 9:07
  • Well, I am not looking for a tool independent of Drupal. For instance, if there is way (perhaps using Drush) to extract the compressed aggregate that Drupal generates, I would be happy to accept that as a solution. May 20, 2013 at 9:11
  • 1
    Drupal compresses and aggregates on the fly, as a rule. That way users of your theme are never left with scrambled, machine-only CSS and are not tied to specific vendor for the lifetime of their website. I guess that's a reason of downvotes. Opensource people doesn't like that. stackoverflow.com/questions/tagged/css seems like a good place, but I'm no expert.
    – Mołot
    May 20, 2013 at 9:24
  • I don't know the answer to your question, but Adaptivetheme (and it's sub themes) are designed with SASS and Compass and make use of the built-in compression. Taking a look at them may give you some ideas. May 20, 2013 at 15:37

1 Answer 1


I'm not 100% sure I'm right in thinking this, but if you're looking for something to reverse the CSS aggregation/compression, but if you are then it doesn't look like there is anything that exists that will give you exactly what was initially compressed. However, the cache Drupal creates is an array that is keyed by the original filename of the cached CSS, so you should be able to find out WHICH CSS files are being cached relatively easily (I think the variable_get('drupal_css_cache_files'); will get the array for you.

If you are looking to mimic what Drupal does when it aggregates and caches your CSS, then take a look at the drupal_build_css_cache() function (which, as an FYI, is called by drupal_aggregate_css()).

As a point of interest, there is also a drupal_build_js_cache as you'd expect.

  • From what I understood, he wants to compress before publishing, not decompress for edit.
    – Mołot
    May 20, 2013 at 10:18
  • That's why I added an (albeit short) answer for both situations :-)
    – Chapabu
    May 20, 2013 at 10:22
  • Oh, apparently I missed it somehow. Sorry.
    – Mołot
    May 20, 2013 at 10:28
  • @Mołot - No worries, I didn't exactly make it obvious :-)
    – Chapabu
    May 20, 2013 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.