Created
May 15, 2020 14:42
-
-
Save FurkanKozen/b6aa15ae5251f416612a68f0a9ce6423 to your computer and use it in GitHub Desktop.
Simple use of Network and Resource Timing APIs in JavaScript
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
//Collects performance metrics for HTML documents. | |
performance.getEntries(); | |
performance.getEntriesByType("navigation")[0]; | |
performance.getEntriesByType("navigation")[0].serverTiming[0]; | |
//Collects performance metrics for document-dependent resources. | |
//Stuff like style sheets, scripts, images, et cetera. | |
performance.getEntriesByType("resource")[0]; | |
performance.getEntriesByType("resource")[0].serverTiming[0]; | |
performance.getEntriesByType("resource")[1]; | |
performance.getEntriesByType("resource")[1].serverTiming[1]; | |
//Indexing continues until the last resource | |
//serverTiming only works if server is setting header values on requests. | |
//https://developers.google.com/web/fundamentals/performance/navigation-and-resource-timing | |
//https://developer.mozilla.org/en-US/docs/Web/API/Performance/getEntries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment