Open claybiockiller opened 1 year ago
"mCh"
is useful to optimize "fromCharCode"
which is found in many definitions. Providing definitions for every sequence of characters that could be possibly optimized with atob
is not an option. I started working on a generic algorithm to optimize arbitrary sequences using different native functions, but in order to implement this feature, many parts of JScrewIt need to be rewritten, so I am thinking to do this in a next major version, without support for certain old engines.
Currently, there is only 1 triplet has batch
atob()
definition:"mCh" == atob("bUNo")
. But there are more triplets which batchatob()
definition are practical: "#!/" (common in URL hashbang grammar) currently costs 1989 chars, whileatob("IyEv")
only costs 1942 chars; "{b:" (sometimes can be seen in object definitions) currently costs 1121 chars, whileatob("e2I6")
only costs 961 chars; "www" (well-known part of domain name) currently costs 990 chars, whileatob("d3d3")
only costs 900 chars. But batchatob()
can go further since string segment made up by triplets mentioned before can be created by only oneatob()
, which is shorter by three-by-three conversion. additionally, some triplets are impractical withatob()
as triplet, but their corresponding base64 string have code shorter than original triplet, hence can be combined into singleatob()
with suitable context. For example, "://" (common in URL header) currently costs 1311 chars, which base64 string "Oi8v" only costs 723 chars, butatob("Oi8v")
costs 1544 chars. Such usage of batchatob()
conversion would be challenging since you need an algorithm to clip out most suitable segment form original string for batchatob()
conversion.