post image is from here

AdvAgg: You Need This

Over the course of writing the last couple posts, I realized I could fill an entire post gushing about the absolute sweetness that is the third-party Advanced CSS and JS aggregation module, or AdvAgg, because, honestly, if you're not using this module, you probably should be.

One of Drupal's most useful features is the fact its core is capable of aggregating the various CSS and JS files you use, which is a really fancy way of saying it will combine them in to single files grouped by what added them (ie. System, module, theme, etc) and doing useful things like trimming out all the whitespace. While this alone leads to a decent performance increase, throwing AdvAgg in to the mix is like taking your already fast car, turbo charging it, super charging it, then throwing on nitrous oxide.

After extracting it and heading to admin/modules, you'll notice that AdvAgg actually consists of several modules, all of which let you turn different parts of your site up to 11. I usually enable the CSS and JS compressors as well as Modifiers. The shared CDN hosting I don't usually bother with because I'm behind a decent CDN anyways and it would mean at least one extra request per page. I also don't worry about the CSS and JS verifiers because I trust Drupal's community at the plugin level and my days of spitting out janky scripts and styles are far, far behind me.

CSS and JS Minifiers

These things, since I've gone 3 paragraphs with no dirty words, are fucking awesome. The CSS minifiers I leave set to the module's default Yui option because, well, it does pretty much all you can do with CSS. JavaScript, however, is an entirely different ball game.When you visit the JavaScript minification options page, the module will give you a list of methods with approximate processing times beside them, ranging from 300ms to 1300ms.

Below, it will recommend you download and install the php_jsmin extension claiming a processing time of a whopping 2ms. You want to build and install that module because it's not lying, the damned thing is so fast I didn't think it was working until I viewed source and checked out an aggregated file.


The main reasons I install this sub module are, one, it lets me move my aggregated files to assets/ right off the web root so they don't wind up in my future expiry bucket and, two, it lets me share aggregated files across my entire multi-site setup where appropriate. Admittedly, my settings are anal enough it rarely happens, but when it does it's an added bonus. I tell it to uses assets/ directly off the web root.


To keep admin/reports a quiet place, we're going to have to do a couple things to keep the module happy, but if you're using the snippets from my previous posts, you'll probably be okay.

The first thing we have to do is make sure we're using one of AdvAgg's more awesome features: If any of its aggregations 404 it will regenerate them, so we rewrite back to the apex host to make sure it does. If you're playing along at home and using htaccess or Nginx config files based on my previous posts, this is the reason the assets redirects exist, otherwise you'll have to roll your own (and remember to use 307 redirects instead of 301 or 302).

The second is really only important if you're using nginx or are living behind a CDN or other kind of origin pull cache that uses HTTP 1.0 requests. By default Nginx will only use gzip content encoding with HTTP 1.1 requests, so you'll need to make sure you have at least the gzip_* lines from the drupal.conf I outline the Apache + Nginx post. This ensures that, when something advertises it accepts gzip as an encoding, the pre-gzipped variant of a static file is served.

The TL;DR for this post is, I guess, if you want build Drupal sites that really tear ass, you're going to need this module so you might as well play around with it because, even over shaky 3G to my dev environment, image-heavy Kraslovision is fast as a flushing toilet.