Skip to content

Instantly share code, notes, and snippets.

@pvdz
Created January 6, 2014 21:26
Show Gist options
  • Save pvdz/8290105 to your computer and use it in GitHub Desktop.
Save pvdz/8290105 to your computer and use it in GitHub Desktop.
Original:
<table id=t><script>with(t)A=function(){for(a=h='';9>a;a++)for(h+="<tr>",c=0;d=" ABCDE"[c];)h+="<td>"+(c++?a?t[d+=a]=t[d]?eval("top[d][V='value']="+(l[d]||"''").replace(/^=/,'')):"<input id=D onfocus=D[V]=[l.D] onblur=A(l.D=D[V])>".replace(/D/g,d):d:a)},A(A(l=localStorage),innerHTML=h)</script>
Innermost for-body could be in loop-part (potential 1b gain but nothing to put there) (+1)
<table id=t><script>with(t)A=function(){for(a=h='';9>a;a++)for(h+="<tr>",c=0;d=" ABCDE"[c];h+="<td>"+(c++?a?t[d+=a]=t[d]?eval("top[d][V='value']="+(l[d]||"''").replace(/^=/,'')):"<input id=D onfocus=D[V]=[l.D] onblur=A(l.D=D[V])>".replace(/D/g,d):d:a));},A(A(l=localStorage),innerHTML=h)</script>
Cache the empty string (0)
<table id=t><script>with(t)A=function(){for(x=a=h='';9>a;a++)for(h+="<tr>",c=0;d=" ABCDE"[c];)h+="<td>"+(c++?a?t[d+=a]=t[d]?eval("top[d][V='value']="+(l[d]||"x").replace(/^=/,x)):"<input id=D onfocus=D[V]=[l.D] onblur=A(l.D=D[V])>".replace(/D/g,d):d:a)},A(A(l=localStorage),innerHTML=h)</script>
Make A a decl (+1)
<table id=t><script>function A(){with(t)for(a=h='';9>a;a++)for(h+="<tr>",c=0;d=" ABCDE"[c];)h+="<td>"+(c++?a?t[d+=a]=t[d]?eval("top[d][V='value']="+(l[d]||"''").replace(/^=/,'')):"<input id=D onfocus=D[V]=[l.D] onblur=A(l.D=D[V])>".replace(/D/g,d):d:a)}A(A(l=localStorage),t.innerHTML=h)</script>
Attempt to eliminate inner c var, failed, -4 and too many cells
<table id=t><script>with(t)A=function(){for(z=a=h='';9>a;z=a++)for(h+="<tr>";d=" ABCDE"[++z-a];)h+="<td>"+(z>a?a?t[d+=a]=t[d]?eval("top[d][V='value']="+(l[d]||"''").replace(/^=/,'')):"<input id=D onfocus=D[V]=[l.D] onblur=A(l.D=D[V])>".replace(/D/g,d):d:a)},A(A(l=localStorage),innerHTML=h)</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment