0

In my Javascript/jQuery app, I make an Ajax call like this:

var t1 = new Date().getTime();
$(target).load(url,function() {
  var t2 = (new Date().getTime() - t1) / 1000;
  console.log("ajax call took "+t2+" secs")
});

In the Vivaldi browser, the call takes increasingly longer each time I call the code:

ajax call took 0.917 secs
ajax call took 1.013 secs
ajax call took 1.179 secs
ajax call took 1.263 secs
ajax call took 1.3 secs
ajax call took 1.668 secs
...

...until it takes several seconds.

When I manually refresh the page, the time seems to be reset.

The problem is not on the server side, as the time consumed by the server side code does not vary.

Also, this does not happen on Chrome, Firefox or Edge.

Any suggestions?

Arne M
  • 87
  • 8
  • Is it literally taking longer to run, or is it just reporting the wrong timing? – Tim Roberts Mar 09 '22 at 19:07
  • Not sure what you mean by "reporting the wrong timing". The jQuery load() function takes longer to run, as shown above, the server side code does not. – Arne M Mar 09 '22 at 19:13
  • What I mean is, can you tell by watching the browser that it really is taking longer and longer, or is actually a bug in the time computation? For example, and this is only a wild example, if variable `t1` were not getting updated each time, for some reason, then the log message would show elapsed time since the beginning, not elapsed time for this run. – Tim Roberts Mar 09 '22 at 19:21
  • Yes, the browser takes longer and longer to respond. – Arne M Mar 09 '22 at 19:31

1 Answers1

0

I think I have found the real source of the problem. Prior to calling .load(), I push the url onto the browser's session history stack. I omitted this line in my code here for clarity, but now it seems like this is the source of the problem:

window.history.pushState({url:url}, null, url);
var t1 = new Date().getTime();
...

If I comment out the pushState() line, the timing of the ajax call is constant, as expected.

Again, this only happens on Vivaldi, and it seems to be a real problem here.

Arne M
  • 87
  • 8