Throttle a function.
$ npm install @zcorky/throttle
// import import throttle from '@zcorky/throttle'; // throttle function resize(e) { console.log('width', window.innerWidth); console.log('height', window.innerHeight); } window.onresize = throttle(resize, 200);