Skip to content

Instantly share code, notes, and snippets.

@decadecity
Last active December 17, 2015 02:59
Show Gist options
  • Save decadecity/5539450 to your computer and use it in GitHub Desktop.
Save decadecity/5539450 to your computer and use it in GitHub Desktop.
Example showing in page timers that can be used as a fall back when the Navigation Timing API is not available.
<!doctype html>
<html>
<head>
<script>window.t_pagestart = new Date().getTime();</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>In page timer example</title>
</head>
<body>
<h1>Lorem ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<script src="jquery.js"></script>
<script>
$(document).ready(function () {
window.t_domready = new Date().getTime();
});
</script>
</body>
</html>
@Jonic
Copy link

Jonic commented May 8, 2013

If your script's executing at the very bottom of the document, you more than likely don't need the DOM ready event, because the DOM's already there and loaded.

Also, If you just want to do simple timing, you can do that in the console, although it looks like this is only useful if you don't then need to do anything with the value it returns: https://developers.google.com/chrome-developer-tools/docs/console#measuring_how_long_something_takes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment