Socket
Socket
Sign inDemoInstall

web-mini

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web-mini

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


Maintainers
1

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()

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc