An experimental JS "compression" pass that stores an index of long, frequently used key names
Keysquash is an experimental JS "compression" pass that stores an index of
long, frequently used key names (e.g.
addEventListener) and refers to that
documentbodyaddEventListener'mousedown'console.log'down' eoffsetX eoffsetYdocumentbodyaddEventListener'mouseup'console.log'up' eoffsetX eoffsetY
Would be transformed into this:
documentbody$__ks__'mousedown'console.log'down' e$__ks_$ e$__ks_adocumentbody$__ks__'mousedown'console.log'down' e$__ks_$ e$__ks_a"_": "addEventListener""$": "offsetX""a": "offsetY"
Which can then get minified using
uglifyjs -cm for further savings.
In practice it's a little smarter about making sure that replacing keys provides a file size improvement too, but make sure to double check this.
This is only worth using in special cases such as js13kgames. I'm not sure of all of the side-effects yet.
npm install -g keysquash
cat index.js | keysquash | uglifyjs -cm