Skip to main content

JavaScript minifier. PLEASE UPDATE TO VERSION >= 2.0.6. Older versions have a serious bug related to comments.

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

As yet, jsmin makes no attempt to be compatible with ECMAScript 6 / ES.next / Harmony. If you’re using it on Harmony 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

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 2.6, 2.7, 3.2, and 3.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 2.6, 2.7, 3.2, and 3.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

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-2.1.4.tar.gz (11.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: jsmin-2.1.4.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jsmin-2.1.4.tar.gz
Algorithm Hash digest
SHA256 c26baf0c1ceccc3ea13328445d22b3b931a7fc8d3c2d00f0f22e10ba14dabbc4
MD5 bffa87d41b2edbabd5f7bcedef07e5fd
BLAKE2b-256 063b4732fa74c6a27ed7f9476be11ee4c49a916d3c5607879455a194f45afe06

See more details on using hashes here.

Provenance

Supported by

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