Relying on feature detection alone for WebSocket is a big mistake though. Websocket can fail for a number of reasons - proxies, stupid ISPs that interfere with HTTP traffic etc.
In Mibbit, the code is something like this:
if(WebSocket in window) {
tryWebsocket();
window.setTimeout(function() {
if (nothingHappened()) useComet()
}, 5*1000);
} else {
useComet();
}
Where comet in this case is keep alive long polling XHR.