Optimizing Custom Scripts

I wonder whether it would make sense to optimize scripts, like to unroll loops and avoid map(), reduce(), etc.? Also, which interpreter/engine runs on the server? Does it support function inlining?

THX.

Chrome V9 engine is used as an interpreter.

Not sure though which script you want to optimize. Can you give an example?

This appears to make some difference:

function satEnh(rgbArr) {
  var avg = (rgbArr[0] + rgbArr[1] + rgbArr[2]) / 3;
  return [
    avg * (1 - sat) + rgbArr[0] * sat,
    avg * (1 - sat) + rgbArr[1] * sat,
    avg * (1 - sat) + rgbArr[2] * sat
  ];  
}