Sitelet https://web.archive.org/web/20200903041913/https://github.com/GoogleChrome/lighthouse/issues/11316
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display "<1" when rounding down to 0 #11316

Open
adamraine opened this issue Aug 25, 2020 · 4 comments
Open

Display "<1" when rounding down to 0 #11316

adamraine opened this issue Aug 25, 2020 · 4 comments

Comments

@adamraine
Copy link
Member

@adamraine adamraine commented Aug 25, 2020

This came up in #11290:

image

The granularity is 1 so the transfer sizes of some payloads get rounded down to 0. In these cases I think it would be better to display something like "<1 KiB" to make it clear that Lighthouse didn't bug out and some small amount of data was fetched. I think this applies to pretty much any unit but are some units better displayed as is?

@patrickhulce
Copy link
Collaborator

@patrickhulce patrickhulce commented Aug 25, 2020

Great idea for the report to do this when value isn't truly 0 👍

9/10 though I would say it's a bug in the audit that it's trying to surface something that had 0 KiB :)

@connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Aug 25, 2020

does i18n complicate this?

@paulirish
Copy link
Member

@paulirish paulirish commented Aug 26, 2020

9/10 though I would say it's a bug in the audit that it's trying to surface something that had 0 KiB :)

yeah i think we should be filtering out any items have have 0 in both columns.

@adamraine
Copy link
Member Author

@adamraine adamraine commented Aug 26, 2020

does i18n complicate this?

Looks like we can't be sure what format the number will be coming out of Intl.NumberFormat:

/**
* @param {number} size
* @param {number=} granularity Controls how coarse the displayed value is, defaults to 0.1
* @return {string}
*/
formatBytesToKiB(size, granularity = 0.1) {
const kbs = this._numberFormatter.format(Math.round(size / 1024 / granularity) * granularity);
return `${kbs}${NBSP2}KiB`;
}

It's still possible to implement this if putting a "<" in front of a number makes sense for all languages, but I'm willing to bet that the "<1" format is not universal.

yeah i think we should be filtering out any items have have 0 in both columns.

@paulirish Are you talking about items that display 0 or have an original value which is exactly 0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.