Skip to main content

web-mini -- efficient css and html minifer inspired by css-html-js-minify

Project description

web-mini

web-mini -- efficient css and html minifer inspired by https://pypi.org/project/css-html-js-minify/

examples

note minify_html does not handle style tags -- handle css minification ( only very basic stuff that works for html too ) inline urself

singlethreaded

import web_mini

print(
    web_mini.html.minify_html(
        r"""
<h1>hello world</h1>

<p>this is my very cool
website :)</p>

<pre>
int main(void) {
    return 0;
}
</pre>
"""
    )
)

print(
    web_mini.css.minify_css(
        r"""
body {
    margin: auto;
    padding: 2rem;
    max-width: 1100px;
    min-height: 100vh;
    text-rendering: optimizeSpeed;
}

li {
    margin: 0.5em;
}

code {
    white-space: pre-wrap !important;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        -webkit-animation-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;

        -webkit-animation-iteration-count: 1 !important;
        animation-iteration-count: 1 !important;

        -webkit-transition-duration: 0.01ms !important;
        -o-transition-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;

        scroll-behavior: auto !important;;
    }
}
"""
    )
)

outputs :

<h1>hello world</h1> <p>this is my very cool website :)</p> <pre>
int main(void) {
    return 0;
}
</pre>
body{margin:auto;padding:2rem;max-width:1100px;min-height:100vh;text-rendering:optimizeSpeed}li{margin:.5em}code{white-space:pre-wrap !important}@media (prefers-reduced-motion:reduce){*,*::before,*::after{-webkit-animation-duration:.01ms !important;animation-duration:.01ms !important;-webkit-animation-iteration-count:1 !important;animation-iteration-count:1 !important;-webkit-transition-duration:.01ms !important;-o-transition-duration:.01ms !important;transition-duration:.01ms !important;scroll-behavior:auto !important;}}

usage with threading

if ur using web-mini with threading make sure to call compileall() so caching doesnt get in the way

import web_mini

web_mini.compileall()

# or :
# web_mini.css.css_fns.compileall()
# web_mini.html.html_fns.compileall()

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

If you're not sure about the file name format, learn more about wheel file names.

web_mini-1.4.1-py2.py3-none-any.whl (20.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file web_mini-1.4.1-py2.py3-none-any.whl.

File metadata

  • Download URL: web_mini-1.4.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for web_mini-1.4.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7325779ee9973b3a95755abe127bfe898029b7be13ae7be6f01b23ffc5c67df3
MD5 7d4c8b126d3b53de5cae092794729fbd
BLAKE2b-256 8481883a576886a6bfe13638ef5dd0d2b3d0a4117ff739cc5ad677e6ea66666b

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