I actually had code (and a working version) where the transition map in scala was serialised to JSON and then embedded but it was a quite a bit of scala code (serialiser, html template) and resulted in a global object. And I needed the utility functions in js anyway.