{"id":13449409,"url":"https://github.com/juancarlospaco/css-html-js-minify","last_synced_at":"2025-03-22T22:32:58.166Z","repository":{"id":27581785,"uuid":"31064450","full_name":"juancarlospaco/css-html-js-minify","owner":"juancarlospaco","description":"StandAlone Async cross-platform Minifier for the Web.","archived":false,"fork":true,"pushed_at":"2023-06-11T18:49:52.000Z","size":1040,"stargazers_count":217,"open_issues_count":15,"forks_count":19,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-03T15:03:17.519Z","etag":null,"topics":["css","css3","html","html5","minify","no-dependencies","python3","scss","xhtml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ciotto/css-html-js-minify","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juancarlospaco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.gpl.txt","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-20T12:42:55.000Z","updated_at":"2025-02-25T21:34:37.000Z","dependencies_parsed_at":"2023-01-16T22:16:36.162Z","dependency_job_id":null,"html_url":"https://github.com/juancarlospaco/css-html-js-minify","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fcss-html-js-minify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fcss-html-js-minify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fcss-html-js-minify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fcss-html-js-minify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juancarlospaco","download_url":"https://codeload.github.com/juancarlospaco/css-html-js-minify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245029166,"owners_count":20549657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","css3","html","html5","minify","no-dependencies","python3","scss","xhtml"],"created_at":"2024-07-31T06:00:37.313Z","updated_at":"2025-03-22T22:32:57.875Z","avatar_url":"https://github.com/juancarlospaco.png","language":"Python","funding_links":[],"categories":["Python","Tools"],"sub_categories":["WebTools"],"readme":"# css-html-js-minify\n\nAsync single-file cross-platform no-dependencies Minifier for the Web. [![GPL License](http://img.shields.io/badge/license-GPL-blue.svg?style=plastic)](http://opensource.org/licenses/GPL-3.0) [![LGPL License](http://img.shields.io/badge/license-LGPL-blue.svg?style=plastic)](http://opensource.org/licenses/LGPL-3.0) [![Python Version](https://img.shields.io/badge/Python-3-brightgreen.svg?style=plastic)](http://python.org) [![Travis report](https://travis-ci.org/juancarlospaco/css-html-js-minify.svg?branch=master \"Travis-C.I. Testing report\")](https://travis-ci.org/juancarlospaco/css-html-js-minify)\n\n![screenshot](https://source.unsplash.com/q78PYnUehV8/800x402 \"Illustrative Photo by https://unsplash.com/@s_erwin\")\n\n\nhttps://pypi.python.org/pypi/css-html-js-minify\n\n```shell\ncss-html-js-minify.py --help\n\nusage: css-html-js-minify.py [-h] [--version] [--wrap] [--prefix PREFIX]\n                             [--timestamp] [--quiet] [--hash] [--zipy]\n                             [--sort] [--comments] [--overwrite]\n                             [--after AFTER] [--before BEFORE] [--watch]\n                             [--multiple] [--beep]\n                             fullpath\n\nCSS-HTML-JS-Minify. StandAlone Async cross-platform Unicode-ready Python3-ready Minifier for the Web.\n\npositional arguments:\n  fullpath         Full path to local file or folder.\n\noptional arguments:\n  -h, --help       show this help message and exit\n  --version        show programs version number and exit\n  --wrap           Wrap output to ~80 chars per line, CSS only.\n  --prefix PREFIX  Prefix string to prepend on output filenames.\n  --timestamp      Add a Time Stamp on all CSS/JS output files.\n  --quiet          Quiet, Silent, force disable all logging.\n  --hash           Add SHA1 HEX-Digest 11chars Hash to Filenames.\n  --zipy           GZIP Minified files as '*.gz', CSS/JS only.\n  --sort           Alphabetically Sort CSS Properties, CSS only.\n  --comments       Keep comments, CSS/HTML only (Not Recommended)\n  --overwrite      Force overwrite all in-place (Not Recommended)\n  --after AFTER    Command to execute after run (Experimental).\n  --before BEFORE  Command to execute before run (Experimental).\n  --watch          Re-Compress if file changes (Experimental).\n  --multiple       Allow Multiple instances (Not Recommended).\n\nCSS-HTML-JS-Minify: Takes a file or folder full path string and process all\nCSS/HTML/JS found. If argument is not file/folder will fail. Check Updates\nworks on Python3. Std-In to Std-Out is deprecated since it may fail with\nunicode characters. SHA1 HEX-Digest 11 Chars Hash on Filenames is used for\nServer Cache. CSS Properties are Alpha-Sorted, to help spot cloned ones,\nSelectors not. Watch works for whole folders, with minimum of ~60 Secs between\nruns.\n\n```\n\n- Takes a full path to anything, a file or a folder, then parse, optimize and compress for Production.\n- If full path is a folder with multiple files it will use Async Multiprocessing.\n- Pretty-Printed colored Logging to Standard Output and Log File on OS Temporary Folder.\n- Set its own Process name and show up on Process lists.\n- Can check for updates for itself.\n- Full Unicode/UTF-8 support.\n- Smooth CPU usage, Single Instance Checking.\n- Can Obfuscate, GZIP and Hash files, also Watch for changes on files.\n- Can execute arbitrary commands after and before running.\n- `*.css` files are saved as `*.min.css`, `*.js` are saved as `*.min.js`, `*.htm` are saved as `*.html`\n\n\n# Screenshots\n\n**Linux:**\n\n![screenshot](https://raw.githubusercontent.com/juancarlospaco/css-html-js-minify/master/linux-css-html-js-compressor.jpg \"Linux 32bit/64bit Python2/Python3\")\n\n**Apple Mac Os X:**\n[ \u003csup\u003e*(Provided by Loggerhead)*\u003c/sup\u003e ](https://github.com/juancarlospaco/css-html-js-minify/issues/7#issuecomment-97280835)\n![screenshot](https://raw.githubusercontent.com/juancarlospaco/css-html-js-minify/master/osx-css-html-js-compressor_terminal.jpg \"Apple Mac Os X Terminal by Loggerhead\")\n\n![screenshot](https://raw.githubusercontent.com/juancarlospaco/css-html-js-minify/master/osx-css-html-js-compressor_iterm2.jpg \"Apple Mac Os X iTerm2 by Loggerhead\")\n\n**MS Windows:**\n\n![screenshot](https://raw.githubusercontent.com/juancarlospaco/css-html-js-minify/master/windows-css-html-js-compressor.jpg \"MS Windows 32bit/64bit Python2/Python3\")\n\n\n# Command-line usage\n\n```bash\ncss-html-js-minify.py file.htm\n\ncss-html-js-minify.py file.css\n\ncss-html-js-minify.py file.js\n\ncss-html-js-minify.py /project/static/\n```\n\n# Python code usage\n\n```python\nfrom css_html_js_minify import process_single_html_file, process_single_js_file, process_single_css_file, html_minify, js_minify, css_minify\n\nprocess_single_html_file('test.htm', overwrite=False)\n# 'test.html'\nprocess_single_js_file('test.js', overwrite=False)\n# 'test.min.js'\nprocess_single_css_file('test.css', overwrite=False)\n# 'test.min.css'\n\nhtml_minify('  \u003cp\u003eyolo\u003ca  href=\"/\" \u003eo \u003c/a \u003e     \u003c!-- hello --\u003e\u003c/p\u003e')\n# '\u003cp\u003eyolo\u003ca href=\"/\" \u003eo \u003c/a \u003e \u003c/p\u003e'\njs_minify('var i = 1; i += 2 ;\\n alert( \"hello  \"  ); //hi')\n# 'var i=1;i+=2;alert(\"hello  \");'\ncss_minify('body {width: 50px;}\\np {margin-top: 1em;/* hi */  }', comments=False)\n# '@charset utf-8;body{width:50px}p{margin-top:1em}'\n```\n\nThe optional arguments that these functions take are almost the same as the command-line flags.\nCheck the list above *(just use add_hash instead of hash)*. Additionally, you can force a specific path for the output files using ``output_path``.\n\n\n# Install\n\n```\npip install css-html-js-minify\n```\nUninstall `pip uninstall css-html-js-minify`\n\n\n# Why?\n\n- **Why another Compressor ?**, there are lots of compressors for web files out there!; *Or maybe not ?*.\n- Many of them only work inside Django/Flask, or frameworks of PHP/Java/Ruby, or can not process whole folders.\n- This project is the big brother of another project that does the inverse, a [Beautifier for the Web.](https://github.com/juancarlospaco/css-html-prettify#css-html-prettify)\n\n\n# Migration\n\nTo keep things simple [KISS](http://en.wikipedia.org/wiki/KISS_principle), the human readable indented commented hackable HTML is kept as `*.htm` and the compressed production-ready as `*.html`. This is inspired from JavaScript/CSS `*.min.js` and `*.min.css`. [We did not \"invent\" this file extension.](http://en.wikipedia.org/wiki/HTM)\n\nTo migrate from typical file extension HTML to HTM, which is the exactly same, you can run this:\n\n```shell\nfind . -name \"*.html\" -exec rename \"s/.html/.htm/\" \"{}\" \\;\n```\n\nThis will make a copy of all `*.html` renaming them as `*.htm` recursively from the current folder. Nothing deleted.\n\n\n# Requisites\n\n- [Python 3.6+](https://www.python.org \"Python Homepage\")\n\n\n# Coding Style Guide\n\n- Lint, [PEP-8](https://www.python.org/dev/peps/pep-0008), [PEP-257](https://www.python.org/dev/peps/pep-0257), [iSort](https://github.com/timothycrosley/isort) must Pass Ok. `pip install pep8 isort`\n- If there are any kind of tests, they must pass. No tests is also acceptable, but having tests is better.\n\n\n# JavaScript support\n\n- ES6 and ES7 and future standards may not be fully supported since they change quickly, mainly driven by Node.JS releases.\n- Future JavaScript support is orphan, if you want to make ES6, ES7 work feel free to send pull request, we will merge it.\n\n\n# Contributors\n\n- **Please Star this Repo on Github !**, it helps to show up faster on searchs.\n- [Help](https://help.github.com/articles/using-pull-requests) and more [Help](https://help.github.com/articles/fork-a-repo) and Interactive Quick [Git Tutorial](https://try.github.io).\n\n\n# Licence\n\n- GNU GPL and GNU LGPL and [MIT](https://github.com/juancarlospaco/css-html-js-minify/issues/65#issuecomment-330983569).\n\nThis work is free software:\nYou can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\nThis work is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\nWithout even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this work.\n\n\n# Example\n\n\u003cdetails\u003e\n\n**Input CSS:**\n\n```css\n/*!\n * preserve commment\n */\n\n\n/* delete comment */\n.class, #NotHex, input[type=\"text\"], a:hover  {\n    font-family : Helvetica Neue, Arial, Helvetica, 'Liberation Sans', sans-serif;\n    border: none;\n    margin: 0 0 0 0;\n    border-color:    fuchsia;\n    color:           mediumspringgreen;\n    background-position:0 0;;\n    transform-origin:0 0;\n    margin: 0px !important;\n    font-weight :bold;\n    color: rgb( 255, 255, 255 );\n    padding : 0.9px;\n    position : absolute;\n    z-index : 100000;\n    color: #000000;\n    background-color: #FFFFFF;\n    background-image: url(\"data:image/jpeg;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=\");\n;}\n;;\n\n```\n\n**Uglify (NodeJS):** *(474 Bytes, 0.189 Secs)*\n\n```css\n/* * 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=\")};\n```\n\n**css-html-js-minify (Python3):** *(469 Bytes, 0.010 Secs)*\n\n```css\n/*!* 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=)}\n```\n\n\u003c/details\u003e\n\n\n# Ethics and Humanism Policy\n\n- May this FLOSS be always Pristine and Clean, No AdWare, No Spamm, No BundleWare, No Infomercial, No MalWare.\n- This project is [LGBTQQIAAP friendly](http://www.urbandictionary.com/define.php?term=LGBTQQIAAP \"Whats LGBTQQIAAP\").\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuancarlospaco%2Fcss-html-js-minify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuancarlospaco%2Fcss-html-js-minify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuancarlospaco%2Fcss-html-js-minify/lists"}