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.
The html.js file is same only that I inserted this line of code in the head section :
<script src={'../src/general/sendData'}/>
The script doesn't show any messages while navigating, only if I refresh the page:
window.onload = function(){
console.log('worked');
}