So I'm trying to do a refresh status in which if the page was refreshed under 5 minutes, it would say "Updated Just Now," and if it was updated over 5 minutes ago, it would say, "Updated Moments Ago." Below is my Javascript:

```
var startTime, endTime;

function start() {
  startTime = performance.now();
};
function end() {
  endTime = performance.now();
  var timeDiff = endTime - startTime; //in ms 
  // strip the ms 
  timeDiff /= 1000;
  var seconds = Math.round(timeDiff);
if (seconds < 10) {
    time = "Updated Just Now";
  } else {
    time = "Updated Moments Ago";
  }
  document.getElementById("demo").innerHTML = time;    
}

window.onload = start
window.onload = end

```

However, it is very buggy and sometimes doesn't work at all. Any help will be appreciated.