Skip to content

Instantly share code, notes, and snippets.

@pagelab
Created May 1, 2014 13:44
Show Gist options
  • Save pagelab/11451924 to your computer and use it in GitHub Desktop.
Save pagelab/11451924 to your computer and use it in GitHub Desktop.
Measuring Critical Rendering Path with navigation timing (Google)
<html>
<head>
<title>Critical Path: Measure</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link href="style.css" rel="stylesheet">
<script>
function measureCRP() {
var t = window.performance.timing,
interactive = t.domInteractive - t.domLoading,
dcl = t.domContentLoadedEventStart - t.domLoading,
complete = t.domComplete - t.domLoading;
var stats = document.createElement('p');
stats.innerText = 'interactive: ' + interactive + 'ms, ' +
'dcl: ' + dcl + 'ms, complete: ' + complete + 'ms';
document.body.appendChild(stats);
}
</script>
</head>
<body onload="measureCRP()">
<p>
Hello
<span>web performance</span>students!
</p>
<div>
<img src="awesome-photo.jpg" />
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment