My app is moderately(?) complicated, with about 150 items on the screen at once. It performs okay, but is a little laggy on older devices (testing on a Samsung S8). I can live with the lagginess, but as soon as I add in a JS module with some simple math and string manipulation, the app starts crashing fairly often, especially if I send a lot of tap events quickly. I can tell it’s the JS causing this because if I take it out of the logic, it never crashes.

Are JS functions particularly slow in Appgyver? Or prone to instability? I’m just wondering how I can fix this because the function would be quite messy to convert to flow functions (if that would even help.) It seemed much cleaner to do that work in JS.

The screen where this is happening is shown below. Users tap in the four grids, and the app does calculations in the background. The JS function takes the coordinates from the grids and creates the labels you see below the grids (e.g. “1 out, 0.5 up”). The table at the bottom also gets updated when they tap, but it isn’t part of the JS module.

The function that appears to be causing the problem:

var x_direction = inputs.x < 0 ? “in” : “out”;

```
var y_direction = inputs.y < 0 ? "down" : "up";
var label = "0 center";
// If abs value of coordinates are non-zero and the same
if(inputs.x !== 0 && Math.abs(inputs.x) == Math.abs(inputs.y)){
label = (Math.abs(inputs.x) * inputs.h_label_unit).toString() + " " + y_direction + " and " + x_direction;
}
else if(Math.abs(inputs.x) > Math.abs(inputs.y)){
label = (Math.abs(inputs.x) * inputs.h_label_unit).toString() + " " + x_direction;
if(inputs.y !== 0) {
label += ", " + (Math.abs(inputs.y) * inputs.v_label_unit).toString() + " " + y_direction;
}
}
else if(Math.abs(inputs.x) < Math.abs(inputs.y)) {
label = (Math.abs(inputs.y) * inputs.v_label_unit).toString() + " " + y_direction;
if(inputs.x !== 0) {
label += ", " + (Math.abs(inputs.x) * inputs.h_label_unit).toString() + " " + x_direction;
}
}
return { result: label };
```

Any ideas?

App 188716.