Aggregate CSS and JS files in Drupal core

Last updated on
17 March 2025

This page has not yet been reviewed by Managing site performance and scalability maintainer(s) and added to the menu.

You can make Drupal perform better by aggregating CSS and JavaScript files. This will save bandwidth and server requests, resulting in faster load times for the users.

Enable caching, and CSS and JavaScript aggregation

  • Go to Configuration > Development > Performance and set "Browser and proxy cache maximum age" to a time span which works well.
  • Under Bandwidth Optimization enable "Aggregate and compress CSS files", and "Aggregate JavaScript files".

Note that enabling "Aggregate JavaScript files" may cause redeclaration in rare cases. The workaround is to disable aggregation for the problematic JavaScript library:

mymodule.somelibrary:
  js:
    js/foo.js: { preprocess: false }

Help improve this page

Page status: No known problems

You can: