From c4794f04ca1323a6888fb9432981797996d80374 Mon Sep 17 00:00:00 2001 From: Sheya Bernstein Date: Thu, 16 Feb 2017 13:27:55 +0000 Subject: [PATCH 1/4] add HTML_MINIFY_AJAX in middleware --- htmlmin/middleware.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htmlmin/middleware.py b/htmlmin/middleware.py index 00eeaee5..233fc73b 100644 --- a/htmlmin/middleware.py +++ b/htmlmin/middleware.py @@ -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'): From 812608a635176ab76afddb179fc9146ae5ca79ae Mon Sep 17 00:00:00 2001 From: Sheya Bernstein Date: Thu, 16 Feb 2017 13:29:37 +0000 Subject: [PATCH 2/4] use spaces --- htmlmin/middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htmlmin/middleware.py b/htmlmin/middleware.py index 233fc73b..01b37f51 100644 --- a/htmlmin/middleware.py +++ b/htmlmin/middleware.py @@ -51,7 +51,7 @@ def can_minify_response(self, request, response): req_ok = False break - if not getattr(settings, 'HTML_MINIFY_AJAX', True) and request.is_ajax(): + if not getattr(settings, 'HTML_MINIFY_AJAX', True) and request.is_ajax(): return False resp_ok = 'text/html' in response.get('Content-Type', '') From 198abd1aaad6490b979c3133f21de6b19c11aec5 Mon Sep 17 00:00:00 2001 From: Sheya Bernstein Date: Thu, 16 Feb 2017 13:31:43 +0000 Subject: [PATCH 3/4] add HTML_MINIFY_AJAX to README --- README.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.rst b/README.rst index f1d99d5e..9a62d713 100644 --- a/README.rst +++ b/README.rst @@ -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 ``True`` if don't want to minify AJAX requests. + Excluding some URLs ------------------- From cfe98aad962b0c5213f1ca12ce3518ea910ca993 Mon Sep 17 00:00:00 2001 From: Sheya Bernstein Date: Thu, 16 Feb 2017 13:32:23 +0000 Subject: [PATCH 4/4] typo --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 9a62d713..fa686b91 100644 --- a/README.rst +++ b/README.rst @@ -72,7 +72,7 @@ You can also optionally specify the ``HTML_MINIFY_AJAX`` setting: HTML_MINIFY_AJAX = False The default value for the ``HTML_MINIFY_AJAX`` setting is ``True``. You only -need to set it to ``True`` if don't want to minify AJAX requests. +need to set it to ``False`` if don't want to minify AJAX requests. Excluding some URLs -------------------