How to call an OCaml function from JS code?

Have a look at function Js.wrap_callback