How to run the script both 'on load' and 'on resize' (on a particular window width!) in jQuery? <p>In my current website project I've integrated <a href="https://github.com/alvarotrigo/fullPage.js" rel="nofollow">Alvaro Trigo's FullPage plugin</a> but since it had a very uncommon behaviour on mobile devices (also due to my project's design requirements), I've decided to switch it off when the viewport width is below 768px. For this purpose I just add a simple if-statement to the script:</p> <pre><code>$(document).ready(function(){ if ($(window).width() &gt; 768 ) { $('#fullpage').fullpage({ // code... code... code... }); } }); </code></pre> <p>The problem is that it only takes effect after refreshing the page; so when I go below 768px and reload the page the plugin is switched off, but when I then resize the browser above the mentioned breakpoint, it's still off (and vice versa). I think I should add some lines of code dealing with resize, but unfortunately my current knowledge of JS/jQ doesn't let me do that. Thanks in advance for your time.</p>