joewalnes / reconnecting-websocket

A small decorator for the JavaScript WebSocket API that automatically reconnects
MIT License
4.21k stars 968 forks source link

Feature detect WebSockets in older clients #43

Closed josh closed 9 years ago

josh commented 9 years ago

It'd be nice to be able to load this script in older clients that don't support WebSockets like IE9.

I think it makes sense to just leave ReconnectingWebSocket undefined so you can feature check it in the same way.

So if you're code was

if ('WebSocket' in window) {
  var ws = new WebSocket('ws://....');
}

You can just change that to

if ('ReconnectingWebSocket' in window) {
  var ws = new ReconnectingWebSocket('ws://....');
}

/cc @joewalnes @mislav

mislav commented 9 years ago

:+1:

joewalnes commented 9 years ago

Agree. Merged. Thanks.

josh commented 9 years ago

@joewalnes thanks!