3 ms·
I am puzzled by how an binary AST makes the code significantly smaller than a minified+gziped version. A JavaScript expression such as: var mystuff = blah + 4
by d--b 9y ago
I am puzzled by how an binary AST makes the code significantly smaller than a minified+gziped version.
A JavaScript expression such as:
var mystuff = blah + 45
Gets minified as
var a=b+45
And then what is costly in there is the "var " and character overhead which you'd hope would be much reduced by compression.
The AST would replace the keywords by binary tokens, but then would still contain function names and so on.
I mean I appreciate the effort that shipping an AST will cut an awful lot of parsing, but I don't understand why it would make such a difference in size.
Can someone comment?
- bryanlarsen 9y agoAccording to a comment by Yoric, they're seeing a 5% improvement in size over minified+gzip. https://news.ycombinator.com/item?id=15046750 https://news.ycombinator.com/item?id=15046750
- AriaMinaei 9y agoAfaik, improving parse time is the big goal here. Parsing is a significant stage of the compile pipeline, perf-wise. Some engines (Chakara at least), defer part of the parsing of the body of a function until the function itself is called, just to save precious milliseconds and not block the first render.
- kannanvijayan 9y agoIt's actually hard to get smaller than compressed minified JS. Source code is actually a very excellent high-level, compact representation of program text. The space optimizations in BinaryJS are to get us back down to the point where we are as good or better than minified compressed JS. The main goal is to allow for much faster parse times, but to do that without compromising other things like compressed source size.