Skip to content

Instantly share code, notes, and snippets.

Created December 21, 2018 20:05
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
}'Total Bytes Saved:', totalBytesSaved)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment