Skip to main content
django-compresshtml
=====================


HTML compressor for django

Why compress HTML code?
=====================

When compressed HTML code, you reduce the size of data transferred from your server to your client, and your pages load faster.

Installing
==========

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

$ [sudo] pip install django-compresshtml

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

All you need to do is add ``compresshtml.middleware.CompressHtmlMiddleware`` to your ``MIDDLEWARE_CLASSES`` and enable the ``COMPRESS_HTML`` setting:

MIDDLEWARE_CLASSES = (
'compresshtml.middleware.CompressHtmlMiddleware',
# other middleware classes
)

COMPRESS_HTML = True

This middleware should be placed before any other middleware that need to read or write the response body so that compression happens afterward.

The default value for the ``COMPRESS_HTML`` setting is ``not DEBUG``. You only need to set it to ``True`` if you want to minify your HTML code when ``DEBUG`` is enabled.

Keeping comments
----------------

The default behaviour of the middleware is remove all comments but conditional comments from HTML. If you want to keep your comments, set the setting ``KEEP_COMMENTS_ON_COMPRESSING`` to ``True``:

KEEP_COMMENTS_ON_COMPRESSING = True

Using the decorator
===================

django-compresshtml also provides a decorator, that you can use only on views you want to minify the response:

from compresshtml.decorators import compressed_response

@compressed_response
def home(request):
return render_to_response('home.html')

development
===========

* Source hosted at `GitHub <https://github.com/kamagatos/django-compresshtml>`
* Report issues on `GitHub Issues <https://github.com/kamagatos/django-compresshtml/issues>`

Pull requests are very welcomed!

Changelog
=========

0.1
-----

* Initial commit

LICENSE
=======

Unless otherwise noted, the django-compresshtml source files are distributed under the BSD-style license found in the LICENSE file.

Metadata

Release files for django-compresshtml 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-compresshtml 0.1.1
File Size Uploaded Provenance Actions
django-compresshtml-0.1.1.tar.gz 2.7 kB Without provenance Details for django-compresshtml-0.1.1.tar.gz

Release files / django-compresshtml-0.1.1.tar.gz

Download URL django-compresshtml-0.1.1.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0611dbfdccaae104435b06ae519a7055aec8ad653211ac9f52fb778fd46b0294
BLAKE2b-256 checksum
How to use checksums
1832060f649a157e32f5915c63934e4bc079dc86d97f5b664d4bc8d0f6c65c42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-compresshtml 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page