{"id":41322,"library":"js-shrink","title":"js-shrink","description":"js-shrink is a supplemental JavaScript minifier that shortens string literals, property names, variable names, and built-in values by replacing frequently used strings with short variable declarations. It preserves property names (no mangling) for safety, making it less effective than full mangling but safe for all property names. This package is typically used alongside a standard minifier like Terser for additional size reduction. It is released on npm under MIT license and receives occasional updates. Key differentiators: focuses on string and property name shortening without mangling, supports source maps, and allows fine-grained control through many options.","status":"active","version":"1.0.19","language":"javascript","source_language":"en","source_url":"https://github.com/brandon942/js-shrink","tags":["javascript"],"install":[{"cmd":"npm install js-shrink","lang":"bash","label":"npm"},{"cmd":"yarn add js-shrink","lang":"bash","label":"yarn"},{"cmd":"pnpm add js-shrink","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The default export is a function. In ESM, use default import; in CJS, use require('js-shrink') which returns the function directly (not a module).","wrong":"const shrink = require('js-shrink').default","symbol":"default","correct":"import shrink from 'js-shrink'"},{"note":"The package exports a single function as the module.exports. There is no named export 'shrink'.","wrong":"const { shrink } = require('js-shrink')","symbol":"shrink (CJS)","correct":"const shrink = require('js-shrink')"},{"note":"This package does not ship TypeScript types. You may need to use @types/js-shrink or declare types manually.","wrong":"import * as shrink from 'js-shrink'","symbol":"TypeScript types","correct":"import shrink from 'js-shrink'"},{"note":"No public type exports; object literal type is inferred from usage.","wrong":"","symbol":"Options interface","correct":"import shrink from 'js-shrink'; const options: Options = { literals: true }"}],"quickstart":{"code":"import shrink from 'js-shrink';\n\nconst code = `function greet(name) { return \"Hello, \" + name; }`;\n\nconst minified = shrink(code, {\n  literals: true,\n  properties: false,\n  variables: true,\n  undeclared: true,\n  values: true,\n  this: false\n});\n\nconsole.log(minified);\n// Might output: function greet(a){return\"Hello, \"+a}","lang":"javascript","description":"Demonstrates basic usage of js-shrink to minify a simple function by shortening literals and variable names."},"warnings":[{"fix":"Set 'all: true' to shrink everything except numbers, classObjects, and functions, or explicitly enable desired features.","message":"Default options do not include 'all': you must explicitly enable each feature (literals, properties, variables, etc.) or set all: true.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Understand that property names are replaced with short variables (not renamed) – they remain the same but are assigned to shorter identifiers.","message":"Property names are not mangled but are shortened in the same way as strings. This is safer but less effective than mangling. Do not expect property renaming like Terser.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Check latest docs for any alternative; currently still supported.","message":"Option 'declarationsPlaceholder', 'declarationsPlaceholderConst', 'declarationsPlaceholderVar' use underscore style; may be renamed in future.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Enable both options to get an inline source map.","message":"Source map generation generates a map object only if 'generateSourceMapObject' is true; otherwise no map is produced. Inline source map requires 'generateSourceMapInline'.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'addit':67 'allow':97 'alongsid':60 'built':22 'built-in':21 'control':101 'declar':33 'differenti':83 'effect':45 'fine':99 'fine-grain':98 'focus':84 'frequent':27 'full':47 'grain':100 'javascript':10,105 'js':2,5 'js-shrink':1,4 'key':82 'less':44 'licens':77 'like':64 'liter':15 'make':42 'mangl':39,48,92 'mani':103 'map':95 'minifi':11,63 'mit':76 'name':17,19,37,54,89 'npm':74 'occasion':80 'option':104 'packag':56 'preserv':35 'properti':16,36,53,88 'receiv':79 'reduct':69 'releas':72 'replac':26 'safe':50 'safeti':41 'short':31 'shorten':13,90 'shrink':3,6 'size':68 'sourc':94 'standard':62 'string':14,29,86 'supplement':9 'support':93 'terser':65 'typic':58 'updat':81 'use':28,59 'valu':24 'variabl':18,32 'without':91","created_at":"2026-06-04T18:51:50.832738+00:00","updated_at":"2026-06-04T18:51:50.832738+00:00","problems":[{"fix":"Use import shrink from 'js-shrink' (ESM) or const shrink = require('js-shrink') (CJS).","cause":"Using named import 'shrink' instead of default import.","error":"shrink is not a function"},{"fix":"Add type:module to package.json or use require('js-shrink') instead.","cause":"Using ESM import syntax in a Node.js environment that expects CommonJS without type:module.","error":"Unexpected token 'export'"},{"fix":"Run npm install js-shrink, then check node_modules directory.","cause":"Package not installed or path incorrect.","error":"Cannot find module 'js-shrink'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/brandon942/js-shrink#readme","github":"https://github.com/brandon942/js-shrink","docs":null,"changelog":null,"pypi":null,"npm":"js-shrink","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}