How to trigger window resize event using vanilla javascript?
<p>I'm trying to trigger resize event using plain js for testing purpose, but <code>window.resizeTo()</code> and <code>window.resizeBy()</code> don't trigger the event according to the modern browsers prevent these actions. I tried jquery <code>$(window).trigger('resize');</code> but it works only for events that attached via jquery like <code>$(window).on('resize', handler);</code>. however in my case the project I am working on uses plain javascript.</p>

<p>example</p>

<pre><code>window.addEventListener('resize', function(){
    console.log('window has been resized !');
});

// or even using global onresize
window.onresize = function() {
    console.log('window has been resized!');
};
</code></pre>