Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ The default value for the ``HTML_MINIFY`` setting is ``not DEBUG``. You only
need to set it to ``True`` if you want to minify your HTML code when ``DEBUG``
is enabled.

You can also optionally specify the ``HTML_MINIFY_AJAX`` setting:


.. code-block:: python

HTML_MINIFY_AJAX = False

The default value for the ``HTML_MINIFY_AJAX`` setting is ``True``. You only
need to set it to ``False`` if don't want to minify AJAX requests.

Excluding some URLs
-------------------

Expand Down
3 changes: 3 additions & 0 deletions htmlmin/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def can_minify_response(self, request, response):
if regex.match(request.path.lstrip('/')):
req_ok = False
break

if not getattr(settings, 'HTML_MINIFY_AJAX', True) and request.is_ajax():
return False

resp_ok = 'text/html' in response.get('Content-Type', '')
if hasattr(response, 'minify_response'):
Expand Down