Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.