Lighthouse: Always display decimal places in JS library size comparison

Created on 12 Sep 2020  ·  4Comments  ·  Source: GoogleChrome/lighthouse

Feature request summary

Currently in the 'Large JavaScript libraries' view, the 'Transfer size' column values omit the decimal place for round sizes. i.e. 18 KiB is displayed instead of 18.0 KiB.

This ticket proposes to always display the digit after the decimal place, even if it is 0.

I am happy to make the necessarily changes if the feature is agreeable with the team 🙂

What is the motivation or use case for changing this?

For people who struggle with their vision this can make it harder to compare the numbers across the rows, as the digit columns do not line up. For example in the below image it can look like date-fns is 18 KiB while luxon is 204 KiB.

lighthouse-sizes

How is this beneficial to Lighthouse?

Improve accessibility.

P3

All 4 comments

Thanks for filing @acutmore! I agree when the granularity is set to tenths all numbers should be displayed to the tenth 👍

I am happy to make the necessarily changes if the feature is agreeable with the team

Sounds good, thanks! Let us know if you need any help.

The relevant code is various functions within https://github.com/GoogleChrome/lighthouse/blob/ec69e56f06b61932712db239c3db1804d260a16a/lighthouse-core/report/html/renderer/i18n.js

NumberFormatter apparently accepts a minimum significant digits: https://tc39.es/ecma402/#conformance

thanks @patrickhulce and @connorjclark. I'll have a go at making the change within the next few days.

also, Math.log10 will be your friend :)
image

Was this page helpful?
0 / 5 - 0 ratings