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.