Created
May 1, 2014 13:44
-
-
Save pagelab/11451924 to your computer and use it in GitHub Desktop.
Measuring Critical Rendering Path with navigation timing (Google)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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