and the SD then needs extra RAM. Realistically that means it's not something you can do at runtime because all variables would need to be relocated.
Or maybe C globals could be above or right below the stack? so JS variables would be right above softdevice and could grow shrink from top to the bottom according to soft device requirements? Basically this https://github.com/espruino/Espruino/blob/master/targetlibs/nrf5x_12/nrf5x_linkers/linker_nrf52_ble_espruino.ld#L9 would start below reserved stack so all data/bss would fit and space for JS variables would be below and not part of this.
That branch I posted earlier should help with the bigger MTU - unfortunately you have to request it when initialising the softdevice, and the SD then needs extra RAM. Realistically that means it's not something you can do at runtime because all variables would need to be relocated.
Even so, I think it would be worth losing a bit of RAM permanently for - maybe not to max out the MTU, but at least to go for something significantly higher than 20.