title: Destroy window.onresize event subscriber
body: <p>If I subscribe to window.onresize (in a single page app), do I need to unsubscribe to avoid a memory leak? If so, how do I do that?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    var heightOutput = document.querySelector('#height');
    var widthOutput = document.querySelector('#width');
  
    function resize() { 
      heightOutput.textContent = window.innerHeight;
      widthOutput.textContent = window.innerWidth;
    }
  
    window.onresize = resize;
  &lt;/script&gt;
  </code></pre>
  
  <p><a href="https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onresize" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onresize</a></p>