EventSourcePolyfill vs native EventSource (Performance wise)

Viewed 709

I see a library which allows custom headers in Header with EventSource.

EventSourcePolyfill

But when I see the network tab the Type shows fetch instead of eventsource Whereas if I use native EventSource it generates type as eventsource.

Is there a difference in performance between fetch and eventsource.

Using Polyfill

const eventSourceInitDict = {headers: {
        'ClientId': '123123123',
        'ClientSecret': 'lllasjdlkasjdlkasdlka'
    }};
const objEventSource1 = new EventSourcePolyfill('https://*****.herokuapp.com/emit-custom-pe?userId=' + '{!$User.Id}', eventSourceInitDict);
objEventSource1.addEventListener('message', function (objEventSourceData) {
    debugger;
});

Using Native EventSource

const objEventSource1 = new EventSource('https://****.herokuapp.com/emit-custom-pe?userId=' + '{!$User.Id}');
objEventSource1.addEventListener('message', function (objEventSourceData) {
    debugger;
});
0 Answers
Related