When I turn on Drupal 7 css and js compression in the performance part, it is aggregating too much files.(5 css files and 5js files). Why?
Is there any way to force drupal to aggregate more the files?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
No, not really, and you wouldn't want to do this.
The thing is, Drupal aggregates CSS files into groups to be able to easily load different CSS sets for different 'media' and 'browser' values, as well as for different pages being viewed, without the need to regenerate them.
If you look into
$groups variable generated by
includes/common.inc, there are 5 keys which different combination of values between each group:
This allows for different groups to be loaded on different pages/in different situations without regenerating them (or including not-needed CSS), which would be the case if only one aggregated CSS file would exist.
You might want to take a look at the Advanced CSS/JS Aggregation contrib module, especially the Bundler Submodule.
The Bundler Submodule might be capable of doing what you want. On top of that, you can also compress JS which might also be useful for you.
Do also check Simple Aggregation contrib module.
You can alter the CSS / JS and regroup everything in one group. This will aggregate into one or multiple CSS / JS files (depending the media types used within CSS declaration and JS files, external, inline, ...)