Counting byte savings using Server-Timing
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