Skip to main content

js-min

PyPI version Publish CodeQL License: MIT

A community fork of the jsmin JavaScript minifier.

Install

pip install min-js

Usage

from js_min import jsmin

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

Command line:

python -m js_min myfile.js

Note: js-min makes no attempt to be compatible with ECMAScript 6 / ES.next / Harmony.

If you are minifying ES6 code, you can use the quote_chars parameter:

from js_min 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 jsmin version 2.2.2 with setuptools<58.

Contributing

Issues and Pull requests are welcome.

The upstream 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 main.

Unless you request otherwise, your GitHub identity will be added to the contributor list below.

Contributors

Historical contributors (chronological commit order):

Users

If your project uses js-min, feel free to open a PR adding it to this list.

  • Your project here

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.

Download files

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

Source Distribution

min_js-3.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

min_js-3.1.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file min_js-3.1.0.tar.gz.

File metadata

  • Download URL: min_js-3.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for min_js-3.1.0.tar.gz
Algorithm Hash digest
SHA256 367ddf534484f9287a2863f8ec595e949e706952257529679bcb34670053018d
MD5 c5dc589aa723a11c8099433e2d1c8500
BLAKE2b-256 6b6055345c565e3926cd5b94fa1a4ac0adf4ed5f02341d5c1543d4dc31e3d65f

See more details on using hashes here.

Provenance

The following attestation bundles were made for min_js-3.1.0.tar.gz:

Publisher: publish.yml on QQSHI13/js-min

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file min_js-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: min_js-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for min_js-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60a398b5952f7187811ee7722ff414145df409d3682ae3dbf184a814188c44ac
MD5 443bf2624d4e58e9545158716115414d
BLAKE2b-256 26e0458f4b8e09182eb9bba2affc37be4541f3cc11b01832cd27a479c6627a4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for min_js-3.1.0-py3-none-any.whl:

Publisher: publish.yml on QQSHI13/js-min

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

3.1.1

2 files

This release

3.1.0 This release

2 files

3.0.2

2 files

Supported by

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