Categories
JavaScript Answers

How to wait for the end of ‘resize’ event and only then perform an action with JavaScript?

Spread the love

To wait for the end of ‘resize’ event and only then perform an action with JavaScript, we set the window.onresize property to the resize event handler.

For instance, we write

window.onresize = () => {
  console.log("resized");
};

to set window.onresize to a function that’s called when we resize the tab or window.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *