Can someone please explain what the author means below by saying that "native XHR streaming" is more efficient than "XHR polling."
I'm very interested to know if there's a more efficient way to stream data from the server to client (using XHR - this is not a question about web-sockets). From what I can tell SSE's basically just provides a API for doing a "chunked" server response and adds some feature like connection resume. Has there actually been a performance increase in the SSE implementation?
While a polyfill will provide a consistent API, be aware that the underlying XHR transport will not be as efficient:
XHR polling will incur message delays and high request overhead. XHR long-polling minimizes latency delays but has high request overhead. XHR streaming support is limited and buffers all the data in memory.
Without native support for efficient XHR streaming of event stream data, the polyfill library can fallback to polling, long-polling, or XHR streaming, each of which has its own performance costs.
High Performance Browser Networking by Ilya Grigorik https://hpbn.co/server-sent-events-sse/#emulating-eventsource-with-custom-javascript