title: Do event listeners have to be removed manually when closing WebSocket connection in browser?
body: <p>I'm using native methods provided by <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API" rel="noreferrer">WebSocket API</a>.</p>
  
  <p>I'm wondering if I need to remove event listeners because <code>removeEventListener</code> method is not mentioned in the <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API" rel="noreferrer">link</a> nor in the MDN example <a href="https://github.com/mdn/samples-server/blob/9bc55b16983007ec7e66dc4da0fad6f0277fb60a/s/webrtc-from-chat/chatclient.js#L85" rel="noreferrer">code</a> for websockets.</p>
  
  <p>I'm using event methods like this:</p>
  
  <pre><code>const ws = new WebSocket(url);
  ws.onopen = () =&gt; {}
  </code></pre>
  
  <p>In addition I'm wondering if I need to remove event listeners if I'm closing the connection with <code>ws.close()</code> method I suppose it will remove the listeners anyway as it's cleaning up.</p>