How to attach OCaml values to DOM elements?

It is often convenient to attach OCaml values to some elements of the page. There are several ways to do that.

  • The first possibility is to use DATA attributes (for example if the page is generated on server side.