Is there a way to compress the Craft CSS for a specific environment?

Currently there is a setting for Javascript, useCompressedJs, set to true by default.


Tells Craft whether to use compressed Javascript files whenever possible, to cut down on page load times.


Is it possible to have a similar option in general.php for CSS?


I don't think there's anything built into Craft. What I do is

{% if craft.config.devMode %}
  <link rel="stylesheet" href="{{craft.config.environmentVariables['assetURL']}}css/style.css">
{% else %}
  <link rel="stylesheet" href="{{craft.config.environmentVariables['assetURL']}}css/style.min.css">
{% endif %}

I use devMode to control whether or not I want the minified css, and I use grunt's cssmin task to build my minified css.

  • That is a great tip for front end CSS. However, I am referring to resources for crafts control panel. I cleaned up the question to clear that up. Dec 7 '14 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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