Skip to content

Instantly share code, notes, and snippets.

@zhjgithub
Last active June 26, 2017 03:37
Show Gist options
  • Save zhjgithub/8dde80400b6af1000cd29b5089830c1b to your computer and use it in GitHub Desktop.
Save zhjgithub/8dde80400b6af1000cd29b5089830c1b to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Critical Path: Measure</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<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.textContent = '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