Usually, you create a WebSocket connection within a SharedWorker when you want multiple tabs or windows of the same browser instance to be able to share that connection. So, if you open multiple tabs on the same site (in this case, GitHub), one single WebSocket connection will be enough for them all.
For example, we use this technique in the client API we provide for our own WebSocket server (ConnectionSharing object).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…