Skip to main content

A powerful HTML whitespace remover

Reason this release was yanked:

This version has one file missing.

Project description

HTML Whitespace remover for Django

Pepy.tech Badge PyPi Version Badge PyPI - Python Version PyPI - License

Introduction :

A powerful tool to optimize HTML

Why use “django_stip_whitespace” ?

  • It speeds up website by reducing the HTML size.

  • Its mostly based on C ( gzip ) and Rust ( minify-html : https://pypi.org/project/minify-html/ ) libraries

  • Can be used with ‘django.middleware.gzip.GZipMiddleware’

  • It can automagically minify inline CSS, JS.

  • Significantly lower bytes transferred ( 246kb > 16kb ) when working with frameworks like AlpineJs and TailwindCSS

Why souldn’t you use django_stip_whitespace ?

  • This Module expects that you write js with line breaks.

So for example if you have a file like this:
<div x-init="
        () => {
            console.log('Hello World')
            console.log("Hello World Again") // This will cause error because theres no ';' to break the line
        }
    "
> </div>

The resulted HTML will have an error and AlpineJS won’t init.

  • Disables the use of &nbsp; in HTML. Although this can be easily mitigated by using CSS pesudo element.

Use this:
selector::before {
    content : '\00a0\00a0'
}

Requirements :

  • Brotli

  • minify-html

  • Django > 3 ( Should work with version 2? )

  • Python 3 ( Should work with all version? )

User guide :

Installation :

Install with pip from pypi:

$ python -m pip install django_stip_whitespace

Install with pip from github ( Development ):

$ python -m pip install https://codeload.github.com/baseplate-admin/django_strip_whitespace/zip/refs/heads/main

Then include it in your django project:

MIDDLEWARE = [
    ...
    "strip_whitespace.middlewares.HtmlStripWhiteSpaceMiddleware.html_strip_whitespace",
]

Or if you like:

MIDDLEWARE += "strip_whitespace.middlewares.HtmlStripWhiteSpaceMiddleware.html_strip_whitespace"

Contributing :

If you like this project add a star. If you have problems or suggestions please put them in the Issue Tracker.

Roadmap :

  • Add line break to InlineJS

  • Add ZStandard Compression ? ( Should Work )

  • Add PyPy support

  • Do not remove ‘&nbsp;‘ from html

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

django_strip_whitespace-0.0.10-py3-none-any.whl (21.0 kB view hashes)

Uploaded Python 3

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