Given long polling, I have never ever understood why websockets became a thing. I’ve never implemented them and never will, it’s a protocol extension where none is necessary.
Websockets can operate outside the request/response model used in this long polling example, and allow you to stream data continuously. They're also a lot more efficient in terms of framing and connections if there are a lot of individual pieces of data to push as you don't need to spin a up a connection + request for each bit.