I have the following code that I run for each HTTP request:
ScriptEngine jsEngine = ScriptEngineManager.new().getEngineByName("nashorn"); jsEngine.eval("some script"); jsEngine.invokeMethod(jsEngine.eval("foo"), "bar");
It works, but it is extremely inefficient, as my immutable JavaScript is evaluated every time. What is the correct way to reuse evaluated JavaScript?
source share