Created
October 19, 2020 18:10
-
-
Save rodrigosobrero/3dda2e18ac20db8a9ebbc2fadb7c8f97 to your computer and use it in GitHub Desktop.
Performance API
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
</head> | |
<body onload="loadResources()"> | |
<script> | |
function loadResources() { | |
var image1 = new Image(); | |
image1.onload = resourceTiming; | |
image1.src = 'http://www.w3.org/Icons/w3c_main.png'; | |
} | |
function resourceTiming() { | |
var resourceList = performance.getEntriesByType("resource"); | |
console.log(resourceList); | |
for (i = 0; i < resourceList.length; i++) { | |
if (resourceList[i].initiatorType == "img") { | |
console.log(resourceList[i].responseEnd - resourceList[i].startTime); | |
console.log('---'); | |
} | |
} | |
} | |
</script> | |
<img id="image0" src="http://www.w3.org/Icons/w3c_home.png"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment