I've been working on something similar in Kotlin called http://kweb.io/. It works but is still pre-1.0. You can manipulate a remote DOM as if it was local to the server and attach event listeners. Feedback welcome.
I'm currently working on a website to use machine learning and game theory to allocate chores in a way that minimizes overall pain. Should have a public demo in a few days.
It's the latter. It establishes a WebSocket connection and issues JavaScript commands to execute from the server. This connection remains persistently to allow bi-directional communication between client and server.
This occurs "behind the scenes", the developer will rarely need to think about it.