In a file with only one form of these two, even if there were thousands of functions, i suspect the max savings would be the bytes of βtoinβ - in a file that had mixed, though, it would be larger.
Thatβs not much savings compared to the massive cost of adding new syntax to the language.
To elaberate a bit on the zip format, here is a grossy oversimplification of how this would work.
If I have a JavaScript file that looks like this:
function foo() { ... }
function bar() { ... }
function baz() { ... }
...
The zip format will effectively find-and-replace every function with a unique, unused symbol, like , then put a map at the top that explains what each symbol means. So, the compressed version will look like this:
So, using func instead of function everywhere will only save you the bytes "tion", as @ljharb mentioned, since the only thing that'll change is that means "func " instead of "function ".
Now, this isn't really how the zip format works, I'm sure this explanation is full of lies and what-not, especially since I don't know all of the details of their algorithm, but that should give the basic idea of it and why such a change wouldn't save many bytes. (I did do a quick lookup to verify this, and found that it actually supports multiple different compression alogirhtms, so the details would vary depending on which one was chosen. But the above explanation still shows off a common compression strategy that I'm sure gets used in one way or another by the different possible compression algorithms within the zip format)
Nah you got that approximately right. The actual details of LZW compression (used in ZIP) are just about how to construct the dictionary efficiently and then the down-and-dirty binary encoding details, but your explanation is correct at a high level.
Actually, functions can be shortened using arrow syntax (usually). The moments when devs actually require "classic" fns instead of arrows, are because of the this value, and those are rarer. However, generators must be defined using the function keyword, there's no arrow syntax for generators.
BTW, I suggest a shorter name like fn.
And remember, these aliases will become reserved words, so any variables named like that (in old code) will cause syntax errors