optimize-js-library-size
Optimize JavaScript library size.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Optimize JavaScript library size.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Make a set of things (code, prose, config, docs) consistent along a dimension the user names, by picking a canonical form and conforming every member to it.
Remove illegal states from data structures by redesigning their types so the illegal states cannot be represented at all.
Remove unnecessary comments from code: tombstones, redundant restatements, and comments a well-named variable or function would replace.
Perform a task with a worker agent, critique it with an adversary agent, and apply the accepted critiques with a reconciler agent.
Replace jargon and imported metaphors in code and prose with concrete, domain-fitting terms a reader understands without translation.
Create a new Claude Code skill following the conventions of existing skills.
| name | optimize-js-library-size |
| description | Optimize JavaScript library size. |
| argument-hint | [path to the library or extra guidance] |
Reduce the size of this JavaScript library.
$ARGUMENTS
Ensure terser is configured:
{
// Assume modern JavaScript
ecma: 2020,
module: true,
toplevel: true,
// Run multiple times
compress: {
passes: 3,
},
// Mangle underscore prefixed properties
mangle: {
properties: {
regex: `^_[^_]+`,
},
},
}
Use node to measure size:
node --input-type=module << 'EOF'
import { readFileSync } from 'fs'
import { gzipSync, brotliCompressSync } from 'zlib'
const raw = readFileSync('REPLACE_ME.js', 'utf8')
const minified = Buffer.from(raw.replace(/^\/\/# sourceMappingURL=[^\n]+$/m, '').trimEnd())
console.log(`Minified: ${minified.length} | Gzipped: ${gzipSync(minified).length} | Brotli: ${brotliCompressSync(minified).length}`)
EOF
terserfunctions with arrow functionsswitch with if and else===/!== with ==/!= when it doesn't change behaviorThese aren't exhaustive. Reason from first principles when none fits cleanly.