I don't think that you'd really want to use this with django-compressor. To my understanding, django-compressor is a utility for joining and minifying multiple JS and CSS files. That's exactly what django-require's optimizer does too, but in a different way!
If you're using RequireJS in your project, then you already know about using AMD style to separate your modules into separate files, importing on module into another using define() and require() calls. When you run ./manage.py collectstatic on your project, django-require uses the RequireJS optimiser to minify all your javascript, then join all javascript files together in the correct order to satisfy their dependencies. It does a similar thing with all your CSS files, based on their @import directives.
To use an example (first with CSS, because it's simpler), in django-compressor, you'd do something like this:
{% compress css %}
<link rel="styleshee" href="/foo.css">
<link rel="styleshee" href="/bar.css">
{% endcompress %}
Whereas using django-require, you'd instead simply do this:
<link rel="styleshee" href="/bar.css">
And at the top of bar.css, @import url(/foo.css). During development, foo.css will be loaded dynamically from bar.css, but after optimization, foo.css will actually be inlined at the top of bar.css, and the whole lot minified. This is actually much simpler to code in your templates, and is particular suited for cloud-based environments like heroku, where pausing a async worker to compile a load of CSS on the fly is a bad idea!
Now, to use a javascript example, you'd traditionally split your javascript files into modules and export their public API into a global variable, something like this:
// foo.js
(function() {
var exports = {
foo: function() {
console.log("foo");
}
}
window.fooModule = exports;
}());
// bar.js
(function() {
fooModule.foo();
}());
You'd then load this modules in your template like so:
{% compress js %}
<script src="/foo.js"></script>
<script src="/bar.js"></script>
{% endcompress %}
Using django-require, you'd define your modules using the AMD syntax, like so:
// foo.js
define(function() {
return {
foo: function() {
console.log("foo");
}
}
});
// bar.js
require(["foo"], function(fooModule) {
fooModule.foo();
});
And then, in your templates, you'd do this:
{% require_module "bar" %}
Which would get rendered as this:
<script data-main="/bar.js" src='/require.js"><script>
When you run the collectstatic, the RequireJS optimizer will detect that bar.js
requires foo.js, and join the two scripts together with foo.js ahead of bar.js. This style encourages code re-use, and has many other benefits out outlined on the RequireJS website (
http://requirejs.org/).
As it happens, you can use django-require to optimize your code, even if you don't use a single AMD definition in your code at all! Even without a build profile, it will still minimise all JS and CSS in your project. However, once your start using RequireJS to organise your code, you'll quickly see that it's worth investing in the syntax and methodology.
tl;dr; - There's no point using django-require with django-compressor, they're both doing the same thing in different ways (although RequireJS is way cooler than the old window-globals style of modular javascript!).
Best,
Dave.