mirror of
https://github.com/nkoehring/250kb-club.git
synced 2025-04-19 13:49:04 +02:00
well, actually rejecting large pages is a good idea
This commit is contained in:
parent
654ce28bd6
commit
4b9543fac7
3 changed files with 13 additions and 8 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -3,19 +3,24 @@
|
|||
import Link from './Link.svelte'
|
||||
import data from './pages.json'
|
||||
|
||||
const rejectThreshold = 256000
|
||||
|
||||
const yellowSizeThreshhold = 200
|
||||
const redSizeThreshhold = 225
|
||||
|
||||
const yellowRatioThreshhold = 50
|
||||
const redRatioThreshhold = 25
|
||||
|
||||
const pages = data.map(page => {
|
||||
const totalWeigth = page.contentWeight + page.extraWeight
|
||||
const size = Math.round(totalWeigth / 1024)
|
||||
const ratio = Math.round(page.contentWeight * 100 / totalWeigth)
|
||||
const pages = data.reduce((acc, page) => {
|
||||
const totalWeight = page.contentWeight + page.extraWeight
|
||||
if (totalWeight > rejectThreshold) return acc
|
||||
|
||||
return { url: page.url, size, ratio }
|
||||
})
|
||||
const size = Math.round(totalWeight / 1024)
|
||||
const ratio = Math.round(page.contentWeight * 100 / totalWeight)
|
||||
|
||||
acc.push({ url: page.url, size, ratio })
|
||||
return acc
|
||||
}, [])
|
||||
|
||||
const sortParameters = ['size', 'ratio']
|
||||
let sortParam = sortParameters[0]
|
||||
|
|
Loading…
Add table
Reference in a new issue