Skip to main content

html minify middleware for django

Project description

django-hmin
===========

Django HTML minification middleware (another one, a little bit faster than django-htmlmin)


Installing
==========

For install django-hmin, run on terminal: ::

$ pip install django-hmin


Using the midleware
===================

All you need to do is add two middlewares to your ``MIDDLEWARE_CLASSES`` and
enable the ``HTML_MINIFY`` setting: ::

MIDDLEWARE_CLASSES = (
# other middleware classes
'hmin.middleware.MinMiddleware',
'hmin.middleware.MarkMiddleware',
)

Note that if you're using Django's caching middleware, ``MarkMiddleware``
should go after ``FetchFromCacheMiddleware``, and ``MinMiddleware``
should go after ``UpdateCacheMiddleware``: ::

MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
'hmin.middleware.MinMiddleware',
# other middleware classes
'django.middleware.cache.FetchFromCacheMiddleware',
'hmin.middleware.MarkMiddleware',
)

You can optionally specify the ``HTML_MINIFY`` setting::

HTML_MINIFY = True

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.


License
===================
Who cares? Use it whatever you want.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-hmin-0.1.tar.gz (2.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page