2👍
✅
Give a try to django-compressor. It’s pretty easy to configure and use.
Quote from docs:
The compress template tag supports a second argument specifying the
output mode and defaults to saving the result in a file. Alternatively
you can pass ‘inline‘ to the template tag to return the content
directly to the rendered page, e.g.:
{% load compress %}
{% compress js inline %}
<script src="/static/js/one.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">obj.value = "value";</script>
{% endcompress %}
would be rendered something like:
<script type="text/javascript" charset="utf-8">
obj = {};
obj.value = "value";
</script>
Source:stackexchange.com