Debouncing Window Resize Event

window.addEventListener('resize', () => {
  window.clearTimeout(window.resizeTimeout)
  window.resizeTimeout = window.setTimeout(() => {
    doSomething()
  }, 500)
})

Source: Debouncing the window resize event - Per Djurner