It obviously largely depends on your application, but
btcd (an alternative bitcoin core implementation) natively provides support for Websockets and has an extension API that offers exactly this type of capability. See the
btcd JSON-RPC API wiki for the available Websocket extension methods and notifications.
There is sample node.js code on the linked wiki, and it works fine from Javascript through a broswer too.
Along the same lines, if you're willing to use Go for your application, there is a robust package,
btcrpcclient which supports Websockets and the btcd extensions to make it easy to create a robust RPC client that automatically maintains the Websocket connection including auto-reconnect capability should the connection be interrupted for some reason and many other features.