Closed iccir closed 8 years ago
Using the current oj 2.0 branch, our test file (tenuto.js
) is 336KB uncompressed and 75KB gzipped.
With the shorter squeeze symbols, tenuto.js
is 302K uncompressed and 73KB gzipped. So a 10% reduction in uncompressed file size. Hmmm.
Tested with the following in OJSymbolTyper.js:
function sToBase52(index)
let c0 = sBase52Digits.charAt(index % 52); index = Math.floor(index / 52);
let c1 = "" + (index % 10); index = Math.floor(index / 10);
let c2 = sBase52Digits.charAt(index % 52); index = Math.floor(index / 52);
let result = c0 + c1 + c2;
let base = 62;
while (index > 0) {
result += sBase52Digits.charAt(index % base);
index = Math.floor(index / base);
}
return result;
One issue with this approach is that UglifyJS may also generate a symbol in the "a1a" format.
This would also change our internal tooling for symbolication. I don't believe this is worth it.
Right now, the squeezer generates identifiers which match the following regex:
\$oj\$[A-Za-z][A-Za-z0-9]+
This results in an average length of 7 characters per identifier in our source base. It's necessary to have the
$oj$
prefix to make symbolication of stack traces avoid false positives.It occurred to me that
[A-Za-z][0-9][A-Za-z]
doesn't match any DOM APIs (although[A-Za-z][0-9]
matchesx1
and others in SVG).Investigate using this prefix instead (all three characters must be present). Identifiers after index 27040 would use:
[A-Za-z][0-9][A-Za-z][A-Za-z0-9]*