{"id":2752,"library":"rjsmin","title":"rjsmin: Fast Javascript Minifier for Python","description":"rJSmin is a javascript minifier written in Python, based on the semantics of jsmin.c by Douglas Crockford. It is a re-implementation aiming for speed, designed for runtime use rather than a preprocessing step, and usually produces the same results as the original `jsmin.c`. The current version is 1.2.5 and it supports Python 2.7 and 3.6+.","status":"active","version":"1.2.5","language":"en","source_language":"en","source_url":"https://github.com/ndparker/rjsmin","tags":["javascript","minifier","web performance","frontend","optimization"],"install":[{"cmd":"pip install rjsmin","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"jsmin","correct":"from rjsmin import jsmin"}],"quickstart":{"code":"from rjsmin import jsmin\n\njs_code = \"\"\"\\\nfunction hello( name ) {\n    /* a comment */\n    return 'Hello, ' + name + '!';\n}\n\"\"\"\n\nminified_code = jsmin(js_code)\nprint(minified_code)\n# Expected output: function hello(name){return'Hello,'+name+'!'}","lang":"python","description":"The `jsmin` function takes a string containing JavaScript code and returns its minified version as a string. An optional `keep_bang_comments` parameter allows preserving comments starting with an exclamation mark."},"warnings":[{"fix":"Ensure your JavaScript code is syntactically correct and well-formed before passing it to rjsmin. Use linters or validate the code beforehand.","message":"rJSmin performs no error detection. Unterminated string, regex, and comment literals are treated as regular JavaScript code and minified as such, which can lead to invalid output without explicit error messages.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Read the entire JavaScript file content into a string before passing it to the `jsmin` function.","message":"rJSmin does not handle streams and requires the complete JavaScript code as a single string input. It cannot process code incrementally from a file stream.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Thoroughly test minified output if exact byte-for-byte compatibility or specific minification behaviors (beyond simple whitespace removal) with the original jsmin.c are critical for your application.","message":"While generally compatible with jsmin.c, rJSmin has subtle behavioral differences. For example, control characters in string/regex literals are untouched, newlines are generally disallowed in string/regex literals (except for ECMA-5 line continuations), and sequences like '+ +' or '- -' are not collapsed to '++' or '--'.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}