write code to bridge js and native optimizers, serializing to json between then