pip install django-compressor
python
INSTALLED_APPS = [
...
'compressor',
...
]
python
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
COMPRESS_ENABLED = True
COMPRESS_OUTPUT_DIR = 'compressed'
html
{% load compress %}
{% compress css %}
<link rel="stylesheet" href="{% static 'css/style1.css' %}">
<link rel="stylesheet" href="{% static 'css/style2.css' %}">
{% endcompress %}
{% compress js %}
<script src="{% static 'js/script1.js' %}"></script>
<script src="{% static 'js/script2.js' %}"></script>
{% endcompress %}
python manage.py collectstatic