title: Script not being executed while navigating, it works only if I refresh the page
body: <p>I'm trying to insert a script on a gatsby project, but the script doesn't load, it loads only if I refresh the page, not while navigating.</p>
  <p>The html.js file is same only that I inserted this line of code in the head section :</p>
  <pre><code>&lt;script src={'../src/general/sendData'}/&gt;
  </code></pre>
  <p>The script doesn't show any messages while navigating, only if I refresh the page:</p>
  <pre><code>window.onload = function(){
   console.log('worked');
   }
  </code></pre>