In python, one can take a string containing python code, compile it and run the resulting code with exec.
Can something similar be done with javascript (any implementation is good). My objective is to get something like javascript's eval but faster.
Thank you
Because of the dynamic nature of javascript, you can't really easily compile it to a lower-level language. That's why spidermonkey, V8 etc are just-in-time (JIT) compilers - they use runtime type information to partially compile fragments, sometimes more efficiently than an ahead-of-time compiler would.
Maybe you want to check out the closure compiler? https://developers.google.com/closure/compiler/