Skip to content

StandAlone Async single-file cross-platform no-dependencies Unicode-ready Python3-ready Minifier for the Web.

Notifications You must be signed in to change notification settings

ciotto/css-html-js-minify

Repository files navigation

css-html-js-minify

Travis report GPL License LGPL License Python Version PyPI Join the chat at https://gitter.im/juancarlospaco/css-html-js-minify Donate

  • StandAlone Async single-file cross-platform no-dependencies Unicode-ready Python3-ready Minifier for the Web.
css-html-js-minify.py --help

usage: css-html-js-minify.py [-h] [--version] [--wrap] [--prefix PREFIX]
[--timestamp] [--quiet] [--obfuscate]
[--checkupdates] [--tests] [--hash] [--gzip]
[--comments] [--overwrite] [--after AFTER]
[--before BEFORE] [--watch]
fullpath

CSS-HTML-JS-Minify. StandAlone Async single-file cross-platform no-
dependencies Unicode-ready Python3-ready Minifier for the Web.

positional arguments:
    fullpath         Full path to local file or folder.

optional arguments:
    -h, --help       show this help message and exit
    --version        show programs version number and exit
    --wrap           Wrap Output to ~80 chars per line, CSS Only.
    --prefix PREFIX  Prefix string to prepend on output filenames.
    --timestamp      Add a Time Stamp on all CSS/JS output files.
    --quiet          Quiet, Silent, force disable all Logging.
    --obfuscate      Obfuscate Javascript. JS Only. (Recommended).
    --checkupdates   Check for Updates from Internet while running.
    --tests          Run all built-in Unit Tests, report and exit.
    --hash           Add SHA1 HEX-Digest 11chars Hash to Filenames.
    --gzip           GZIP Minified files as '*.gz', CSS/JS Only.
    --comments       Keep Comments, CSS/HTML Only (Not Recommended)
    --overwrite      Force overwrite all in-place (Not Recommended)
    --after AFTER    Command to execute after run (Experimental).
    --before BEFORE  Command to execute before run (Experimental).
    --watch          Re-Compress if file changes (Experimental).

CSS-HTML-JS-Minify: Takes a file or folder full path string and process all
CSS/HTML/JS found. If argument is not file/folder will fail. Check Updates
works on Python3. StdIn to StdOut is deprecated since may fail with unicode
characters. SHA1 HEX-Digest 11 Chars Hash on Filenames is used for Server
Cache. CSS Properties are AlphaSorted,to help spot cloned ones,Selectors not.
Watch works for whole Folders, with minimum of ~60 Secs between runs.
  • Takes a full path to anything, a file or a folder, then parse, optimize and compress for Production.
  • If full path is a folder with multiple files it will use Async Multiprocessing.
  • Pretty-Printed colored Logging to Standard Output and Log File on OS Temporary Folder.
  • No Dependencies at all, just needs Python Standard Built-in Libs.
  • Set its own Process name and show up on Process lists.
  • Can check for updates for itself.
  • Full Unicode/UTF-8 support.
  • Smooth CPU usage.
  • Can Obfuscate, GZIP and Hash files, also Watch for changes on files.
  • Can execute arbitrary commands after and before running.
  • *.css files are saved as *.min.css, *.js are saved as *.min.js, *.htm are saved as *.html

Screenshots:

Linux:

screenshot

Apple Mac Os X: (Provided by Loggerhead) screenshot

screenshot

MS Windows:

screenshot

Usage:

css-html-js-minify.py file.htm

css-html-js-minify.py file.css

css-html-js-minify.py file.js

css-html-js-minify.py /project/static/

Install permanently on the system:

PIP: (Recommended!)

sudo pip3 install css-html-js-minify

PIP from Git:

sudo pip3 install git+https://raw.githubusercontent.com/juancarlospaco/css-html-js-minify/master/css-html-js-minify.py

WGET:

sudo wget -O /usr/bin/css-html-js-minify https://raw.githubusercontent.com/juancarlospaco/css-html-js-minify/master/css-html-js-minify.py
sudo chmod +x /usr/bin/css-html-js-minify
css-html-js-minify

MANUALLY:

Why?:

Input CSS:

/*!
 * preserve commment
 */


/* delete comment */
.class, #NotHex, input[type="text"], a:hover  {
    font-family : Helvetica Neue, Arial, Helvetica, 'Liberation Sans', sans-serif;
    border: none;
    margin: 0 0 0 0;
    border-color:    fuchsia;
    color:           mediumspringgreen;
    background-position:0 0;;
    transform-origin:0 0;
    margin: 0px !important;
    font-weight :bold;
    color: rgb( 255, 255, 255 );
    padding : 0.9px;
    position : absolute;
    z-index : 100000;
    color: #000000;
    background-color: #FFFFFF;
    background-image: url("data:image/jpeg;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=");
;}

;;

Uglify (NodeJS): (474 Bytes, 0.189 Secs)

/* * preserve commment */ .class,#NotHex,input[type="text"],a:hover {font-family:Helvetica Neue,Arial,Helvetica,'Liberation Sans',sans-serif;border:0;margin:0;border-color:fuchsia;color:mediumspringgreen;background-position:0 0;transform-origin:0 0;margin:0 !important;font-weight:bold;color:#fff;padding:.9px;position:absolute;z-index:100000;color:#000;background-color:#fff;background-image:url("data:image/jpeg;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=")};

css-html-js-minify (Python3): (469 Bytes, 0.010 Secs)

/*!* preserve commment */ .class,#NotHex,input[type=text],a:hover{font-family:Helvetica Neue,Arial,Helvetica,'Liberation Sans',sans-serif;border:0;margin:0;border-color:#f0f;color:#00fa9a;background-position:0 0;transform-origin:0 0;margin:0 !important;font-weight:700;color:#fff;padding:.9px;position:absolute;z-index:100000;color:#000;background-color:#FFF;background-image:url(data:image/jpg;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=)}

Migration:

  • Too keep things simple KISS, the human readable indented commented hackable HTML is keep as *.htm and the Compressed Production-ready as *.html. This is inspired from JavaScript/CSS *.min.js and *.min.css. We didnt "invent" this file extension.

To Migrate from tipical file extension HTML to HTM, which is the exactly same, you can run this:

find . -name "*.html" -exec rename "s/.html/.htm/" "{}" \;

This will make a copy of all *.html renaming them as *.htm recursively from the current folder. Nothing deleted.

Requisites:

  • Python 3.x (or Python 2.x, or PyPy 2.x, or PyPy 3.x, or Python Nightly)

Coding Style Guide:

  • Lint, PEP-8, PEP-257, PyLama, iSort must Pass Ok. pip install pep8 pep257 pylama isort
  • If theres any kind of Tests, they must Pass Ok, if theres no Tests, its ok, if Tests provided, is even better.

Contributors:

Hall of Fame
  • Please Star this Repo on Github !, it helps to show up faster on searchs.
  • Ad-Hocracy Meritocracy: 3 Pull Requests Merged on Master you become Repo Admin. Join us!
  • Help and more Help and Interactive Quick Git Tutorial.

Licence:

Donate, Charityware :

About

StandAlone Async single-file cross-platform no-dependencies Unicode-ready Python3-ready Minifier for the Web.

Resources

Stars

Watchers

Forks

Packages

No packages published