Package: jsmin
JavaScript minifier.Usagefromjsminimportjsminwithopen('myfile.js')asjs_file:minified=jsmin(js_file.read())You can run it as a commandline tool also:python -m jsmin myfile.jsNB:jsminmakes no attempt to be compatible withECMAScript 6 / ES.next / Harmony.
The current maintainer does not intend to add ES6-compatibility. If you would
like to take over maintenance and updatejsminfor ES6, please contactTikitu de Jager. Pull requests are also
welcome, of course, but my time to review them is somewhat limited these days.If you’re usingjsminon ES6 code, though, you might find thequote_charsparameter useful:fromjsminimportjsminwithopen('myfile.js')asjs_file:minified=jsmin(js_file.read(),quote_chars="'\"`")Where to get itinstall the packagefrom pypiget the latest releasefrom latest-release on githubget the development versionfrom master on githubPython 2 support removedPython 2 support was removed in version 3.0.0. If you need to support Python 2, please use version 2.2.2 with setuptools<58.ContributingIssuesandPull requestswill be gratefully received on Github. The project used to be hostedon bitbucketand old issues can still be
found there.If possible, please make separate pull requests for tests and for code: tests will be added to thelatest-releasebranch while code will go tomaster.Unless you request otherwise, your Github identity will be added to the contributor’s list below; if you prefer a
different name feel free to add it in your pull request instead. (If you prefer not to be mentioned you’ll have to let
the maintainer know somehow.)Build/test statusBoth branches are tested with Travis:https://travis-ci.org/tikitu/jsminThelatest-releasebranch (the version on PyPI plus any new tests) is tested against CPython 3.
Currently:If that branch is failing that means there’s a new test that fails onthe latest released version on pypi, with no fix yet
released.Themasterbranch (development version, might be ahead of latest released version) is tested against CPython 3.
Currently:Ifmasteris failing don’t use it, but as long aslatest-releaseis passing the pypi release should be ok.Contributors (chronological commit order)Dave St.Germain(original author)Hans weltarTikitu de Jager(current maintainer)https://bitbucket.org/rennatNick AlexanderGennady KovsheninMatt MolyneauxAlbert WangBen BradshawChangelogv3.0.0 (2021-09-08) Ben BradshawBreaking Change: Removed support for Python 2Removed usage of use_2to3 in setup.pyv2.2.2 (2017-05-01) Tikitu de JagerAdd license headers to code files (fixes i#17)Remove mercurial files (fixes #20)v2.2.1 (2016-03-06) Tikitu de JagerFix #14: Infinite loop onreturn x / 1;v2.2.0 (2015-12-19) Tikitu de JagerMerge #13: Preserve “loud comments” starting with/*!These are commonly used for copyright notices, and are preserved by various
other minifiers (e.g. YUI Compressor).v2.1.6 (2015-10-14) Tikitu de JagerFix #12: Newline following a regex literal should not be elided.v2.1.5 (2015-10-11) Tikitu de JagerFix #9: Premature end of statement caused by multi-line comment not
adding newline.Fix #10: Removing multiline comment separating tokens must leave a space.Refactor comment handling for maintainability.v2.1.4 (2015-08-23) Tikitu de JagerFix #6: regex literal matching comment was not correctly matched.Refactor regex literal handling for robustness.v2.1.3 (2015-08-09) Tikitu de JagerReset issue numbering: issues live in github from now on.Fix #1: regex literal was not recognised when occurring directly after{.v2.1.2 (2015-07-12) Tikitu de JagerIssue numbers here and below refer to the bitbucket repository.Fix #17: bug when JS starts with comment then literal regex.v2.1.1 (2015-02-14) Tikitu de JagerFix #16: bug returning a literal regex containing escaped forward-slashes.v2.1.0 (2014-12-24) Tikitu de JagerFirst changelog entries; see README.rst for prior contributors.Expose quote_chars parameter to provide just enough unofficial Harmony
support to be useful.