Closed ethanlal04 closed 4 months ago
Thanks @ethanlal04 for the suggestion!
We use Terser to minify the script, which does variable renaming, among other size reduction techniques. You can see the minified script of the recent version as an example. In addition, the size that people care about the most, is the gzipped minified bundle (VanJS's gzipped minified bundle is 1.0kB), as gzip compression is usually performed on the server before the HTTP transmission.
Thanks a lot, I didnt know that. I'll close this then.
Hey, Im surprised no one did this but here's the idea: Instead of using descriptive variable names in the implementation code, we can use single-letter characters. This should dramatically reduce the file size. Ive even tried it below:
Here I renamed only variables in the global scope, but this can also be applied to local variables. The number of characters (ignoring linebreaks and whitespace) dropped from 3817 to 3044. That's a lot.
Funnily there were exactly 26 variables in the global scope which could be mapped to the 26 letters of the alphabet.
I know this will make maintenance impossible, but we can put a table at the start of the file that maps the alphabet to its descriptive name (or even a short sentence).
Like this:
Also multiple local comment tables for variables of local scopes
All this can be removed before building for production.
U guys already use let instead of const for naming variables, I don't see why this cant be done. Thoughts?