Created
December 21, 2018 20:05
-
-
Save cvazac/c9ffb2563fe70c00b0c4479460ab59ae to your computer and use it in GitHub Desktop.
Counting byte savings using Server-Timing
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
window.addEventListener('load', function() { | |
let totalBytesSaved = 0 | |
for (const {encodedBodySize, serverTiming} of performance.getEntriesByType('resource')) { | |
for (const {name, description} of serverTiming || []) { | |
if (name === 'disk') { | |
totalBytesSaved += parseInt(description) - encodedBodySize | |
} | |
} | |
} | |
console.info('Total Bytes Saved:', totalBytesSaved) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment