Last active
July 2, 2018 14:03
-
-
Save nuc/02a11d72fa96bc57df9cfe35e51934f1 to your computer and use it in GitHub Desktop.
Perf notes from https://www.youtube.com/watch?v=V8oTJ8OZ5S0
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
<!-- | |
Browser support: partial | |
Success rate: 30%-90% depending on browser | |
Can prefetch HTML: yes | |
--> | |
<link rel="prefetch" href="index.html" /> |
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
function getTimeToInteractive() { | |
const domInteractive = window.performance.timing.domInteractive; | |
const requestStart = window.performance.timing.requestStart; | |
return domInteractive - requestStart; | |
} | |
/* | |
* returns: [ | |
* { | |
* name: 'haha.js', | |
* duration: 12313, | |
* transferSize: [bytes || 0 if served from cache] | |
* }] | |
*/ | |
function getResourceEntries() { | |
return window.performance.getEntriesByType('resource') || []; | |
} | |
/* | |
* Browser support: full | |
* Success rate: > 95% | |
* Can prefetch HTML: no | |
*/ | |
function prefetchResource(resourceURL) { | |
const xhrRequest = new XMLHttpRequest(); | |
xhrRequest.open('GET', resourceURL, true); | |
xhrRequest.send(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment