Here is my weird function that let my users create their own javascript code
function evalThisFunction(functionBody){
var func;
eval("func = " + functionBody);
return func;
}
But after minification with Closure Compiler (http://closure-compiler.appspot.com/), I get this result :
function a(b){eval("func = "+b);}
Do you see a way I can modify my weird function so it will still works after minification?
Yes, use the Function constructor:
Alternatively, you can swap out the above code entirely for
Function
, it seems to do what you want anyway.eval
has scoping issues.