Is there a way to get how long ago a page was loaded using javascript, without having first recorded the time to a javascript variable on page load? I'm hoping to create a scriptlet (javascript bookmark) that I can run on any web page and have it output how much time has passed since the browser loaded the page.
All of the "time spent on a page" solutions I've found so far rely on recording the time when the page first loads, which requires either access to modify a site, or a browser plugin. Is there no document property that stores when the page was loaded (started, finished, etc.) which can be accessed in javascript?
You could use window.performance.timing.loadEventEnd
:
> performance.timing.loadEventEnd
1424280020354
window.performance.timing
provides timestamps for the following page load lifecycle events, in order:
Source: Navigation Timing API on MDN
The Navigation Timing API is currently supported by most modern browsers. Exceptions: Safari < 8 on OSX, Safari on iOS and Opera Mini. - caniuse.com.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With