ai / size-limit

Calculate the real cost to run your JS app or lib to keep good performance. Show error in pull request if the cost exceeds the limit.
MIT License
6.48k stars 1.82k forks source link

Add customisation for improving performance culture #325

Open jochemvogel opened 1 year ago

jochemvogel commented 1 year ago

I recently thought about this and maybe others agree on this. Why not add customisation to the messages shown in the CLI and CI.

For example. I updated line 156 of create-report.js to:

if (typeof check.loadTime !== 'undefined') {
 rows.push(['Loading time', formatTime(check.loadTime), 'for ~1000 users per month'])
}

Can't find a way to modify the loading time. Currently it's set to Slow 3G (400kb/s & 2000ms latency). I would like to update it to the speed of our users.

This issue is not about solving this particular wish, it's about others as well. When possible to customise those messages, it will help to create awareness for the engineers.

image

Could elaborate on this and dive deeper into it, but I first want to see if people agree on this.

Possibly add it to the package.json. Just a rough draft:

"size-limit": [
  {  
     "path": "./clients/dashboard/build/static/js/vendorsMain.*.bundle.js",
     "customConfig": {
         "downloadSpeed": "1200 kb",
         "latency": "800 ms",
         "audienceMessage": "for ~600 users"
  }
],
ai commented 1 year ago

The best way to do it right now is to use JSON output and generate text output by custom JS code.

If you have a simple way to add a customization to Size Limit (for instance, by plugins), send PR.

jochemvogel commented 1 year ago

Ah ok, thanks. Makes sense. Is there any way to modify the Slow 3G settings? I've been looking for it for a while now, but looks like it's nowhere configured (which I don't believe).

I could update the docs so others can find it as well.

ai commented 1 year ago

No, we did not plan to make it customizable.

jochemvogel commented 1 year ago

Will have a look the coming days to see if it's worth my time. Otherwise I'll close this issue. Thank you.

zernie commented 1 month ago

@ai Sorry, why isn't it customizable? 99% of our clients are not on slow 3G so it'd be really helpful to have a more realistic metrics

ai commented 1 month ago

@zernie if nobody want to send PR, it means that feature is not very popular.