title: Run Javascript function if page load, scroll and resize
body: <p>I have a question about running a Javascript function if the page is loaded, on scrolling and on resizing.</p>
  <p>I created a function in Javascript and I will use this by one simple call like</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
  dataView('.result');
  &lt;/script&gt;
  </code></pre>
  <p>What I don't want</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
  window.addEventListener(&quot;scroll&quot;, function(){
      dataView('.result');
  });
  
  window.addEventListener(&quot;onload&quot;, function(){
      dataView('.result');
  });
  
  window.addEventListener(&quot;resize&quot;, function(){
      dataView('.result');
  });
  &lt;/script&gt;
  </code></pre>
  <p>What is a good solution to program a function with this options?</p>