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.1.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.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: min_js-3.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ecd42c531a1628a65df86127f90199ed8c71801adaa99e70578096b3ebd931a5
MD5 e3010e252ca8ed6ad45774b79ebabb00
BLAKE2b-256 8447e027c7ffd5b02c8fcc77a4998709d66725b6c2f66774d43425de2a5d9d60

See more details on using hashes here.

Provenance

The following attestation bundles were made for min_js-3.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: min_js-3.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f3bf061c72398b1d9d6af9a6970a2b427fe38ccd1bf53ba5e0b770b213a43c0
MD5 40db6ce75468b6a9baeeb1da12ea45ae
BLAKE2b-256 22d08d3b19f678d1493f6f02d2ddb8faa78585d6c01b876edbc7072419e146eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for min_js-3.1.1-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

This release

3.1.1 This release

2 files

3.1.0

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