Skip to main content

JavaScript minifier.

Project description

JavaScript minifier.

Usage

from jsmin import jsmin
with open('myfile.js') as js_file:
    minified = jsmin(js_file.read())

You can run it as a commandline tool also:

python -m jsmin myfile.js

NB: jsmin makes no attempt to be compatible with ECMAScript 6 / ES.next / Harmony. The current maintainer does not intend to add ES6-compatibility. If you would like to take over maintenance and update jsmin for ES6, please contact Tikitu de Jager. Pull requests are also welcome, of course, but my time to review them is somewhat limited these days.

If you’re using jsmin on ES6 code, though, you might find the quote_chars parameter useful:

from jsmin import jsmin
with open('myfile.js') as js_file:
    minified = jsmin(js_file.read(), quote_chars="'\"`")

Where to get it

Python 2 support removed

Python 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.

Contributing

Issues and Pull requests will be gratefully received on Github. The project used to be hosted on bitbucket and old issues can still be found there.

If possible, please make separate pull requests for tests and for code: tests will be added to the latest-release branch while code will go to master.

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 status

Both branches are tested with Travis: https://travis-ci.org/tikitu/jsmin

The latest-release branch (the version on PyPI plus any new tests) is tested against CPython 3. Currently:

https://travis-ci.org/tikitu/jsmin.png?branch=latest-release

If that branch is failing that means there’s a new test that fails on the latest released version on pypi, with no fix yet released.

The master branch (development version, might be ahead of latest released version) is tested against CPython 3. Currently:

https://travis-ci.org/tikitu/jsmin.png?branch=master

If master is failing don’t use it, but as long as latest-release is passing the pypi release should be ok.

Contributors (chronological commit order)

Changelog

v3.0.0 (2021-09-08) Ben Bradshaw

  • Breaking Change: Removed support for Python 2

  • Removed usage of use_2to3 in setup.py

v2.2.2 (2017-05-01) Tikitu de Jager

  • Add license headers to code files (fixes i#17)

  • Remove mercurial files (fixes #20)

v2.2.1 (2016-03-06) Tikitu de Jager

  • Fix #14: Infinite loop on return x / 1;

v2.2.0 (2015-12-19) Tikitu de Jager

  • Merge #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 Jager

  • Fix #12: Newline following a regex literal should not be elided.

v2.1.5 (2015-10-11) Tikitu de Jager

  • Fix #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 Jager

  • Fix #6: regex literal matching comment was not correctly matched.

  • Refactor regex literal handling for robustness.

v2.1.3 (2015-08-09) Tikitu de Jager

  • Reset 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 Jager

  • Issue 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 Jager

  • Fix #16: bug returning a literal regex containing escaped forward-slashes.

v2.1.0 (2014-12-24) Tikitu de Jager

  • First changelog entries; see README.rst for prior contributors.

  • Expose quote_chars parameter to provide just enough unofficial Harmony support to be useful.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsmin-3.0.1.tar.gz (13.9 kB view details)

Uploaded Source

File details

Details for the file jsmin-3.0.1.tar.gz.

File metadata

  • Download URL: jsmin-3.0.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for jsmin-3.0.1.tar.gz
Algorithm Hash digest
SHA256 c0959a121ef94542e807a674142606f7e90214a2b3d1eb17300244bbb5cc2bfc
MD5 8b68605422eb47c8fcdb02a78efc068b
BLAKE2b-256 5e73e01e4c5e11ad0494f4407a3f623ad4d87714909f50b17a06ed121034ff6e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page