{"id":4061,"library":"jsmin","title":"jsmin","description":"jsmin is a Python library and command-line tool for minifying JavaScript code, based on Douglas Crockford's original jsmin.c. It removes unnecessary whitespace and comments to reduce file size. The current version is 3.0.1. The project is actively maintained, though the maintainer has stated they do not intend to add ECMAScript 6 (ES6) compatibility, indicating a focused maintenance cadence for its existing feature set.","status":"maintenance","version":"3.0.1","language":"en","source_language":"en","source_url":"https://github.com/tikitu/jsmin/","tags":["javascript","minifier","web development","build tools","frontend"],"install":[{"cmd":"pip install jsmin","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"jsmin","correct":"from jsmin import jsmin"}],"quickstart":{"code":"from jsmin import jsmin\n\njs_code = '''\n// This is a comment\nfunction greet(name) {\n    console.log(\"Hello, \" + name + \"!\");\n}\ngreet(\"World\");\n'''\n\nminified_js = jsmin(js_code)\nprint(minified_js)\n\n# Example with a file (hypothetical, requires myfile.js to exist)\n# try:\n#     with open('myfile.js', 'r') as js_file:\n#         minified_from_file = jsmin(js_file.read())\n#         print(minified_from_file)\n# except FileNotFoundError:\n#     print(\"myfile.js not found for file example.\")","lang":"python","description":"Minify a JavaScript string directly, or read from a file, process, and print the minified output. The primary function `jsmin()` takes a string of JavaScript code and returns the minified version."},"warnings":[{"fix":"Upgrade to Python 3 or pin `jsmin` to version `2.2.2` for Python 2 projects: `pip install 'jsmin==2.2.2'`.","message":"Version 3.0.0 removed support for Python 2. If you require Python 2 compatibility, you must use version 2.2.2.","severity":"breaking","affected_versions":"3.0.0+"},{"fix":"Ensure your JavaScript input is compatible with older ECMAScript standards (ES5-ish) or consider alternative minifiers for ES6+ code. For specific cases like template literals or certain quoted strings, the `quote_chars` parameter might offer limited help: `jsmin(code, quote_chars=\"'\\\"`\")`.","message":"`jsmin` does not attempt to be compatible with ECMAScript 6 (ES6 / ES.next / Harmony) syntax. Using it on modern JavaScript code may result in incorrect minification or errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always validate your JavaScript code using a linter or by running it in an environment (like a browser or Node.js) before feeding it to `jsmin`.","message":"`jsmin` expects syntactically correct JavaScript as input. Providing invalid JavaScript may lead to minification failures or corrupted output.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware of this behavior when expecting all comments to be removed. Use `/*!` for comments you wish to retain (e.g., copyright notices).","message":"Comments starting with `/*!` (often called 'loud comments' or 'licence comments') are preserved during the minification process since version 2.2.0. Other comments are stripped.","severity":"gotcha","affected_versions":"2.2.0+"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}