Skip to content

Commit

Permalink
Fix fetchWithBrotli function and add date to results.json
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Jan 29, 2024
1 parent 05e8afc commit 258b204
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
15 changes: 8 additions & 7 deletions benchmarks/critical-css-for-docs-sites/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function fetchWithBrotli(url) {
'Accept-Encoding': 'br'
}
})
return response;
return response
} catch (error) {
if (error.response.status === 404) {
return error.response
Expand All @@ -28,12 +28,12 @@ async function fetchWithBrotli(url) {
}

async function fetchAndCalculateCSS({ name, url }) {
const response = await fetchWithBrotli(url);
const $ = cheerio.load(response.data.toString());
const domain = response.request.protocol + '//' + response.request.host;
const response = await fetchWithBrotli(url)
const $ = cheerio.load(response.data.toString())
const domain = response.request.protocol + '//' + response.request.host
let totalInternalCSSSize = 0
let totalInternalCSSBrotliSize = 0
let totalExternalCSSSize = 0;
let totalExternalCSSSize = 0
let totalExternalCSSBrotliSize = 0
let externals = []
let internals = []
Expand Down Expand Up @@ -71,7 +71,7 @@ async function fetchAndCalculateCSS({ name, url }) {
size: styleSize,
brotliSize: styleBrotliSize
})
});
})

return {
name,
Expand All @@ -83,7 +83,8 @@ async function fetchAndCalculateCSS({ name, url }) {
totalExternalCSSSize,
totalExternalCSSBrotliSize,
externals,
internals
internals,
date: new Date().toISOString()
}
}

Expand Down
27 changes: 17 additions & 10 deletions benchmarks/critical-css-for-docs-sites/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"size": 96,
"brotliSize": 52
}
]
],
"date": "2024-01-29T03:51:16.140Z"
},
{
"name": "React",
Expand All @@ -64,7 +65,8 @@
"brotliSize": 15976
}
],
"internals": []
"internals": [],
"date": "2024-01-29T03:51:15.998Z"
},
{
"name": "Vue.js",
Expand All @@ -82,7 +84,8 @@
"brotliSize": 21082
}
],
"internals": []
"internals": [],
"date": "2024-01-29T03:51:16.365Z"
},
{
"name": "Angular",
Expand Down Expand Up @@ -181,7 +184,8 @@
"size": 1883,
"brotliSize": 507
}
]
],
"date": "2024-01-29T03:51:16.716Z"
},
{
"name": "Bootstrap",
Expand Down Expand Up @@ -209,7 +213,8 @@
"brotliSize": 7332
}
],
"internals": []
"internals": [],
"date": "2024-01-29T03:51:18.010Z"
},
{
"name": "Tailwind CSS",
Expand All @@ -227,15 +232,16 @@
"brotliSize": 37021
}
],
"internals": []
"internals": [],
"date": "2024-01-29T03:51:17.367Z"
},
{
"name": "Master CSS",
"url": "https://rc.css.master.co/docs",
"totalCSSSize": 30674,
"totalCSSBrotliSize": 6553,
"totalCSSBrotliSize": 6557,
"totalInternalCSSSize": 28435,
"totalInternalCSSBrotliSize": 5706,
"totalInternalCSSBrotliSize": 5710,
"totalExternalCSSSize": 2239,
"totalExternalCSSBrotliSize": 847,
"externals": [
Expand All @@ -249,7 +255,7 @@
{
"tag": "<style>",
"size": 7080,
"brotliSize": 430
"brotliSize": 434
},
{
"tag": "<style id=\"master\">",
Expand All @@ -266,6 +272,7 @@
"size": 19,
"brotliSize": 23
}
]
],
"date": "2024-01-29T03:51:16.924Z"
}
]

0 comments on commit 258b204

Please sign in to comment.