.. _django-sekizai_support: django-sekizai Support ====================== Django Compressor comes with support for django-sekizai_ via an extension. django-sekizai provides the ability to include template code, from within any block, to a parent block. It is primarily used to include js/css from included templates to the master template. It requires django-sekizai to be installed. Refer to the `django-sekizai docs`_ for how to use ``render_block`` Please note that the sekizai integration does not work with :ref:`offline compression `. See `this issue`_ for details. Usage ----- In templates which either extend base templates or are included by other templates, use any of these directives to import Stylesheets and JavaScript files: .. code-block:: django {% load static sekizai_tags %} {% addtoblock "css" %}{% endaddtoblock %} {% addtoblock "css" %}{% endaddtoblock %} {% addtoblock "js" %}{% endaddtoblock %} {% addtoblock "js" %}{% endaddtoblock %} {% addtoblock "js" %}{% endaddtoblock %} Note that some files are loaded by the browser directly from a CDN and thus can not be compressed by django-compressor. Therefore the Sekizai compressor checks whether a file is compressible, and only if so, concatenates its payload. .. code-block:: django {% load sekizai_tags %} ... {% render_block "css" postprocessor "compressor.contrib.sekizai.compress" %} ... {% render_block "js" postprocessor "compressor.contrib.sekizai.compress" %} In the above example, we render StyleSheets inside the ```` element and JavaScript files just before closing the ```` tag. Here, we first render some references to CSS and JavaScript files, served from external sources. Afterwards all local files are concatenated and optionally minified. In the last step all references to deferred files are rendered. .. _django-sekizai: https://github.com/ojii/django-sekizai .. _django-sekizai docs: https://django-sekizai.readthedocs.io/en/latest/ .. _this issue: https://github.com/django-compressor/django-compressor/issues/351