How long ago did I load a page?

javascript, time

Solution

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:

- navigationStart

- unloadEventStart

- unloadEventEnd

- redirectStart

- redirectEnd

- fetchStart

- domainLookupStart

- domainLookupEnd

- connectStart

- connectEnd

- secureConnectionStart

- requestStart

- responseStart

- responseEnd

- domLoading

- domInteractive

- domContentLoadedEventStart

- domContentLoadedEventEnd

- domComplete

- loadEventStart

- loadEventEnd

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.

Problem

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?

Original source

Related problems