engine.io-client icon indicating copy to clipboard operation
engine.io-client copied to clipboard

Use native whatwg instead?

Open jimmywarting opened this issue 4 years ago • 2 comments

https://github.com/socketio/engine.io-client/blob/9c79ba65f51fef44e860bbeea1626fa40c3f967c/lib/socket.js#L5-L6

How about replacing this two with just URL & URLSearchParams?

jimmywarting avatar Jul 11 '21 09:07 jimmywarting

That's a good remark, thanks! I think we would need to provide a polyfill for some browsers though:

  • https://caniuse.com/urlsearchparams
  • https://caniuse.com/url

Which makes this change less appealing. What do you think?

Related: https://github.com/socketio/engine.io-client/issues/674

darrachequesne avatar Jul 13 '21 05:07 darrachequesne

At least if they are available natively the polyfill would be GC'ed and wouldn't need to do a much JIT parsing

  • Possible to conditionally import?
  • Let developer decide if they wish to use a polyfill or not. Some are already dropping support for IE entirely, even microsoft themselves.
// README.md example

// Required for IE 11 support
globalThis.URL = globalThis.URL || require('url').URL
globalThis.URLSearchParams = globalThis.URLSearchParams || require('url').URLSearchParams

const engine = require('engine.io-client')

ppl could also use core-js or polyfill.io

i guess core-js is based on some browser usage config or something like that

jimmywarting avatar Jul 13 '21 07:07 jimmywarting