Skip to main content

html minify for django

Project description

html minify for django

Why minify HTML code?

One of important points on client side optimization is minify HTML, with minified HTML code, you reduce the size of data transferred from your server to your client, and your pages load faster.

Installing

For install django-htmlmin, run on terminal:

$ [sudo] pip install django-htmlmin

Using the midleware

All you need to do is add htmlmin.middleware.HtmlMinifyMiddleware to your MIDDLEWARE_CLASSES:

MIDDLEWARE_CLASSES = (
    # other middleware classes
    'htmlmin.middleware.HtmlMinifyMiddleware',
)

Using the html_minify function

If you are not working with Django, you can invoke the html_minify function manually:

from htmlmin.minify import html_minify
html = '<html>    <body>Hello world</body>    </html>'
minified_html = html_minify(html)

Here is an example of Flask view:

from flask import Flask
from htmlmin.minify import html_minify

app = Flask(__name__)

@app.route('/')
def home():
    rendered_html = render_template('home.html')
    return html_minify(rendered_html)

development

Pull requests are very welcomed! Make sure your patches are well tested.

running the tests

if you are using a virtualenv, all you need is:

$ make test

community

irc channel

#cobrateam channel on irc.freenode.net

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-htmlmin-0.0.1.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file django-htmlmin-0.0.1.tar.gz.

File metadata

File hashes

Hashes for django-htmlmin-0.0.1.tar.gz
Algorithm Hash digest
SHA256 738113b13b0125ed0272810e38e9e891771fcf968c12e4eb94b67acec72471ee
MD5 377e166b0869986806d16275a2dd3bf6
BLAKE2b-256 4ca472f6f29e77780bc6dc27f9314db3d6e643c7c57c63bfd6360750acd71149

See more details on using hashes here.

Supported by

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