Just use django-compressor (https://github.com/jezdez/django_compressor). It does this as well as minifying and compressing static assets.
In fact, I'll file a bug suggesting this on django_compressor right now.
In our case we have a utility machine that compiles media and deployes it but that machine doesn't even run a webserver at all...
https://github.com/jezdez/django_compressor/blob/develop/com...