Have just run Google pagespeed over my newly created drupal 6 site, and it reports:

Minifying the following JavaScript resources could reduce their size by 15.6KiB (12% reduction).

    Minifying http://[sites]/sites/default/files/js/js_9f19b87ffb72ca233ea7e45dda2f20f9.js could save 15.3KiB (18% reduction). See optimized version or Save as.

The above file was generated through drupal's default JavaScript aggregation method, but apparently it could be 18% smaller (which is a big deal for this site). What approach is considered the best when it comes to minifying JavaScript on a drupal site without breaking any existing code?

  • I don't think this is really a Drupal specific question, it could relate to any minification of JavaScript and would therefore be better asked at StackOverflow.
    – Decipher
    Commented Mar 8, 2011 at 10:07
  • 4
    The drupal specific part would be that any solution would need to integrate with drupal and replace core JS aggregation files with minified versions. Changed title to hopefully make this clearer
    – wiifm
    Commented Mar 8, 2011 at 10:10

3 Answers 3


You could use the Javascript Aggregator module for that or install PageSpeed (the Apache module, not the Firebug extension) if you use Apache and can install extensions (e.g. not a shared webhost), combined with Drupal's own aggregation, with the added benefit that PageSpeed could also minify CSS.

  • Using nginx as the webserver, not too sure if Google pagespeed integrates with that just yet
    – wiifm
    Commented Mar 8, 2011 at 10:15
  • Ah indeed, you're better off with the module than PageSpeed in that case.
    – wildpeaks
    Commented Mar 8, 2011 at 10:20

I created a new module to tackle a lot of the aggregation issue & I hope to get a large chunk of it into D8; and yes it's a D6 module: http://drupal.org/project/advagg. Uses the jsmin+ lib for compression of JS and the CSSTidy lib for CSS compression. Main advantage of this is the css/js aggregate file doesn't change names unless it needs to; these files also have a 1 year cache lifetime & has imagecache generation so 404s to your CSS file should be a thing of the past.

Update: AdvAgg 7.x is being developed and comes with minification of JS as an optional sub module. Other D7 options:

  • 1
    From the description on the page, I'm sensing a subtle hint that I should install this module :D Good job, I will try it out.
    – wildpeaks
    Commented Mar 10, 2011 at 11:12
  • 1
    Yeah, I did try this module for the site, the only issue was it minified the CSS in such a way that the site broke. I was unsure of whether this is due to the CSS minification engine or some poorly coded CSS ;) In any case, I was only after JS minification, as the JS is substantially larger than the CSS. Will there be in option in this module to disable CSS minification? Nice work BTW
    – wiifm
    Commented Mar 10, 2011 at 21:28
  • Just disable the CSS Compression module. It uses the CSSTidy library if you where wondering.
    – mikeytown2
    Commented Mar 12, 2011 at 0:38
  • @mikeytown2 Thank you very much for such a great module. I have some problem with one of my websites css files sometime not load question is here [drupal.stackexchange.com/questions/128649/… and website link [living.md/]i was wandering if I use advgg do i need to enable drupal Aggregate and compress CSS files and Aggregate JavaScript files. under performance. I cant find any documentation for the module any link to some basic setting?
    – Yama
    Commented Sep 11, 2014 at 18:49

You can use Minify module to do the same. Minify module minify the JavaScript using Google compiler. It also works with "Aggregate JavaScript files" so you can also get advantage of combining multiple JavaScript files which is default option in Drupal 7.

Minify module also minify HTML.

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.