{"id":26432293,"url":"https://github.com/marcel0ll/jsminify","last_synced_at":"2025-03-18T06:17:46.195Z","repository":{"id":78563073,"uuid":"323209594","full_name":"marcel0ll/jsminify","owner":"marcel0ll","description":"A JavaScript minifier built on top of tree-sitter","archived":false,"fork":false,"pushed_at":"2022-02-13T21:22:28.000Z","size":118,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T04:05:09.498Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcel0ll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-21T02:22:10.000Z","updated_at":"2023-10-04T15:48:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"67117def-1487-494c-a777-a62313f8ff0b","html_url":"https://github.com/marcel0ll/jsminify","commit_stats":{"total_commits":127,"total_committers":2,"mean_commits":63.5,"dds":0.4251968503937008,"last_synced_commit":"e17ccda4eaf32e137c73d538007cecf6fa8896b3"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcel0ll%2Fjsminify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcel0ll%2Fjsminify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcel0ll%2Fjsminify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcel0ll%2Fjsminify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcel0ll","download_url":"https://codeload.github.com/marcel0ll/jsminify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244058466,"owners_count":20391110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-18T06:17:45.482Z","updated_at":"2025-03-18T06:17:46.187Z","avatar_url":"https://github.com/marcel0ll.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsminify\n\n\"jsminfy\" is a JS minifier written in C. It uses tree-sitter-javascript grammar\nto create a parser and uses tree-sitter-visitor to visit each node of a\nJavaScript AST. For each visited node it generates javascript code that is\nminified.\n\n## Installing\n\n`npm i @lotuz/jsminify`\n\n## Usage\n\n`jsminify [OPTIONS] [FILE]`\n\n**FILE must always come last**\n\n### OPTIONS\n\n* -h, --help: For printing jsminify help\n* -v, --version: For printing jsminify version\n* -d, --debug: For debugging minification, also helpful for bug report\n* -o, --output: Sets the output file\n* (WIP) -c, --keep-comments: Keeps comments while minifying\n* (WIP) -b, --beautify: For pretty printing file\n\n## Building\n\nInitialize git submodules with: `git submodules init --recursive --update`\n\nInstall node-gyp dependencies according to platform and run:\n\n`node-gyp configure`\n`node-gyp build`\n\n## Debugging \n\nDebugging relies on gdb\n\nChange `require` inside `index.js` to the one with DEBUG in the path\n\n- `node-gyp rebuild --debug`\n- `gdb node`\n- `run index.js [OPTIONS] [FILE]`\n\n## Dependencies (all installed as git submodules under libs/)\n\n\u003e please let me know better ways to handle this\n\n- [tree-sitter](https://github.com/tree-sitter/tree-sitter)\n- [tree-sitter-javascript](https://github.com/tree-sitter/tree-sitter-javascript)\n- [tree-sitter-visitor](https://github.com/marcel0ll/tree-sitter-visitor)\n\n## Publishing\n\n* Bump version on jsminify.c and package.json\n* Create git tag\n* Push tag\n* Wait for CI builds\n* run `prebuildify-ci download`\n* run `npm publish`\n\n## How I tested this (for now)\n\nI used jsminify to minify:\n\n- angular.js\n- bootstrap.js\n- d3.js\n- ember.prod.js\n- htmlminifier.js\n- jquery-3.4.1.js\n- lodash.js\n- math.js\n- phaser.js\n- react.js\n- particles.js\n\nthen I used prettier to beautify the code and diffed the files against the same\nprocess done by Uglifyjs.\n\nThe diffs shows what other minifications are done by uglifyjs that could be \nimplemented by jsminify, missing minificaiton opportunities and bugs.\n\nBetter tests are currently being written in [test/](./test/README.md)\n\n## Profiling\n\nI am using `gcc.sh` to build jsminify and then using `perf` and `flamegraph`\nto create somekind of visualization of what is going on. \n\nI would love to hear about better ways to profile this.\n\n## Improvements\n\nDue to how tree-sitter works it might be possible to only re-minify edited\nparts of a file while developing. Not sure about this, and not sure if this\nwould be valuable to anyone as it is already really fast to minify using\njsminify.\n\n## Roadmap\n\n- [ ] 1.0.0\n  * [ ] MINIFICATION\n    - [ ] Write article about jsminify 1.0.0\n    - [x] Write enough tests for common javascript\n    - [x] Improve scientific number printing\n    - [x] Improve operator spacing\n    - [x] Improve decimal digits precision printing: ECMA-256 only requires up\n          to 21 digits. Chrome apparently crops at 16. So:\n          0.89081309152928522810 becomes 0.8908130915292852\n    - [x] Remove comma dangle\n    - [x] Check memory allocation/deallocation\n    - [x] Check \"includes\"\n    - [x] Test in Windows\n    - [x] Test in Mac\n\n- [ ] 1.1.0\n  * [ ] COMPRESSION\n    - [ ] Transform scoped parameters identifiers in shorter versions. ex.:\n          `function(foo){foo()}` =\u003e `function(a){a()}`\n    - [ ] Remove unnecessary \";\" on last statement in a block statement\n  * [ ] BEAUTIFY (should this be part of jsminify or another minimal library?)\n    - [ ] Ensure beatiful output\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcel0ll%2Fjsminify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcel0ll%2Fjsminify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcel0ll%2Fjsminify/lists"}