Closed hazzik closed 3 years ago
Btw, the length of JSFuck-encoded jsfuck.js is reduced from 4,711,510 characters to 487,754 characters (10 times!)
Well, this is a great improvement! Many thanks for taking the time @hazzik !
Also deployed this version to jsfuck.com.
Thanks!
@hazzik I was curious how big code of jsfuck.js create small-jsfuck and it creates 258kb of code - Im surprised that pure jsfuck only ~double this result after your fix-es (!). However it looks like they are not deploye yet
Optimize wrapper based on https://github.com/aemkei/jsfuck/pull/107#issuecomment-684646669.
Replace
\
in escape character witht
(cheapest symbol outside of base 16 numbers) on compile stage. On runtime stage replacet
back with\
before passing the string into theFunction
constructor. To avoid usingreplace(x,y)
function which requires 2 arguments usesplit()
andjoin()
functions.The "cost" of additional characters is about ~100.
Without this optimization one unmapped caracter has encoded length of about 3600 characters. Every additional unmapped character adds 2000 to the total length.
For example, the length of
~
is 3605,~~
is 5600, and~~~
is 7595.The loader with replace has encoded length of about 5300 characters and every additional character adds 100 to the total length.
In the same example the length of
~~
becomes 5371 and~~~
-- 5463.So, when we have more than one unmapped character we want to encode whole input except select characters (that have encoded length less than about 70) into an escape sequence.