petroleyum
petroleyum

Reputation: 678

Can I use a filter on all compress blocks except for one?

In my settings for compressor I'm using SlimIt for most of my javascript:

COMPRESS_JS_FILTERS = ['compressor.filters.jsmin.SlimItFilter', ]

Some of my js files shouldn't go through SlimIt though because the file is already minified, or the javascript throws some error when its minified with other files. My template block ends up looking like this:

{# code that I minify #}
{% block compressed_libs %}
    {% compress js %}
        <script src="/static/js/compress_this.js"></script>
        <script src="/static/js/also_compress_this.js"></script>
        ...
    {% endcompress %}
{% endblock %}

{# code that shouldn't minify #}
{% block non-compressible_libs %}
    <script src="/static/js/already.min.js"></script>
    <script src="/static/js/breaks-everything.js"></script>
{% endblock %}

Can I set different compress filter rules for different blocks/files so that my "non-compressible" files can still be concatenated together by compressor while skipping SlimIt?

Upvotes: 8

Views: 294

Answers (1)

petroleyum
petroleyum

Reputation: 678

As approxiblue said, it doesn't look there's a way to specify which filters to use per compress block in a template (in Compressor 1.5).

I'll update this answer someone comes up with something.

It seems like this could be solved by adding a parameter to the compress template tag to allow it to return a CompressorNode with a flag to skip the filter in base.py hunks()

I'll see what the Compressor community thinks about this, but let me know if you have any ideas.

Upvotes: 1

Related Questions