Browser websocket fallback and support


Simple question: I saw on the site of several fallbacks for websockets (

But I can not find (even after a long google session) which browsers use which fallback. The reason I'm asking is that I want to avoid a long polling fallback so I need to know which browsers and versions would use that.

[EDIT ]Seeing as this got downvoted I need to carify myself:

I need to know which browsers/versions eventually fall back to long polling. I can not simple assume the use of long polling in my case because long polling would present problems. Hope this makes it more clear and why I could not find it as easily..

[EDIT 2] Sorry for being so unclear:

I kinda see now that I basically asked which browsers use a fallback. But that's not what I meant to ask as I already know this. I meant to ask how to detect or know which fallback will be used. For my application flash is no problem, but long polling could present problems. Thanks!

Problem courtesy of: jansmolders86


If you want to know which browers work ahead of time, then Can I Use is a great reference.

If you want to detect support in your application when it is running, then you can just test for the existence of the WebSocket object:

if (WebSocket) {
    // Use websockets
} else {
    // Fallback will be used

(This code should be run on the client side, in the browser - not in your node.js app itself)


If you need to know exactly what fallback is being used, create a socket, then check the property. (So if your socket is called "socket", you'll be checking It can be one of the following:

  • websocket
  • htmlfile
  • xhr-polling
  • jsonp-polling
Solution courtesy of: andypaxo


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.