Skip to main content

Optimizing Custom Scripts

  • April 17, 2024
  • 2 replies
  • 0 views

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.

2 replies

Chrome V9 engine is used as an interpreter.

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


Sentinel-Hub custom scripts

Color Correction with Sentinel Hub

A repository of custom scripts that can be used with Sentinel-Hub services.

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
  ];  
}