Late answer, but still I wanted to post my answer here. I ran into a similar problem when I have a background server check function with setInterval built into it. But in my code there are many possibilities to run the same function according to some other criteria. Therefore, to make sure that I donβt think about it, I simply used local storage to ensure that the function is not called again and again.
This function is in my HTML file,
function serverCheck(value){ localStorage.setItem("isFunctionRunning",1); setInterval(checkServerStatus, value); }
The snippet below is in my other JS file,
function xyz(){
source share