JScrewIt (different solutions: 16117, 14747, and 5903 characters)
Javascript engines are not identical; slight implementation differences may cause code that works in a browser not to work in another one.
In case of lipogrammatic code like JSFuck - which largely relies on hacks to encode things as short as possible - incompatibilities are even larger.
For example, the code generated by JSFuck for alert("Hello World!")
does not run on Internet Explorer.
If this is an acceptable limitation, we can still drop the size down to 16117 22174 characters (I cannot include the whole code directly because answer size is limited to 30000 characters):
http://jsfiddle.net/ep2jqsj4/1/
A code that works on Internet Explorer too, but not so on some older browsers, takes 14747 characters to encode:
http://jsfiddle.net/bbxfqboq/
Finally, if it's ok to have code that runs on current Firefox [update] and Safari [end update] only, we could do it with 5903 5911 characters:
http://jsfiddle.net/pkyLy0j8/1/
I encoded all of those with JScrewIt.
You can find other encoders similar to JSFuck listed on Esolang: http://esolangs.org/wiki/JSFuck.
I tried all of them and I have to say JScrewIt seems to be the best one (and also the only one that works in all browsers), though I havent't analysed how it works in detail.
Another interesting encoder is 6chars.js, which generates larger output for short input like alert("Hello World!")
, but when the input gets longer it performs better than the other encoders because it encodes characters as numbers.
Numbers are shorter to write in JSFuck but require extra overhead to decode. Unfortunately, 6chars.js only works in Chrome and I can't say if it's being still actively developed.
It would be interesting to know if there are more of such encoders. If one could join methods used by different encoders in one tool it would be possible to produce even shorter solutions.
Can we get
$
and=
as well, please? Otherwise I don't think we can best the generator. – John Dvorak – 2014-01-08T08:53:19.6232@JanDvorak I understand your point but it may somehow break the point of this challenge: use JSFuck. – Pierre Arlaud – 2014-01-08T09:35:33.320
Heh, didn't realize someone turned this into a "language". – Griffin – 2014-01-08T13:29:47.437
Because of the limited character set, surely after compression (as is common in all modern HTTP servers and browsers) this is better than minification! – Nick T – 2014-12-06T17:30:52.913