optimize-js-library-size
Optimize JavaScript library size.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Optimize JavaScript library size.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
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.