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

Total byte audit reports full URL #2312

Merged

Conversation

johnboxall
Copy link
Contributor

Currently the total-byte-weight audit only reports getURLDisplayName for URLs.

This can make it challenging to understand what resource the audit is talking about, as sites we work with include 3rd party scripts with mystery names.

Without the complete URL, it is impossible to create detailed CI tests that fail if certain resources are bigger than a threshold. In our case, we often do not control the size of all assets on the page, so we don't want to fail on the overall threshold... just thing we have control on.

This change displays the full URL.

Before After
image image

I used the test page https://lighthouse-url-example.surge.sh/ with a few examples of URLs that we may encounter in the wild.

With the longer URLs, the styling could probably use some love (I could also imagine terrible ideas like having the full URL available on hover) – happy to pursue that if this is a direction you'd like to head in. Assuming this is a direction you're looking at going in, also happy to update the relevant tests.

❤️

@wardpeet
Copy link
Collaborator

As I do like the idea we changed it for a reason as we didn't want to show the full url as it is irrelevant in most cases.

Maybe better to work with a toggle button or tooltip..

Cc @ebidel @paulirish

@paulirish
Copy link
Member

@johnboxall thx for the patch! appreciate it.

We've intended to have the full URL there in a tooltip. But based on the patch, it looks like it's not there. :/

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah definitely would like to see this change happen. This is part of a broader undertaking to move all the getURLDisplayName calls out of the audits and into the renderer where it's just used for the span text but can view the full URL in tooltip or inspect.

@johnboxall how do you feel about taking a stab at setting the title over in the _renderURL method in lighthouse-core/report/v2/renderer/details-renderer.js?

@johnboxall
Copy link
Contributor Author

@patrickhulce sure 👍

@johnboxall
Copy link
Contributor Author

👨‍🎨

image

@wardpeet
Copy link
Collaborator

LGTM! Just have to fix the linting errors where travis throws on.

@johnboxall
Copy link
Contributor Author

@wardpeet 💁

Just have to fix the linting errors where travis throws on.

So about that 😛

1️⃣ It's not clear to me how I'd resolve this type warning and the related error:

/tmp/tmpvGobNX/front_end/audits2/lighthouse/renderer/details-renderer.js:75: WARNING - actual > parameter 1 of Util.parseURL does not match formal parameter
 found   : (string|undefined)
 required: string
     const parsedURL = Util.parseURL(text.text);
                                     ^^^^^^^^^

Relaxing the type on parseURL seems like the wrong move – I could do something silly like make an intermediate method with a more forgiving type definition ... Any pointers?

2️⃣ It's looks like I'll need to re-generate sample_v2.json to resolve these errors with something like:

node lighthouse-cli/test/fixtures/static-server.js
npm run start -- --output=json --output-path=lighthouse-core/test/results/sample_v2.json http://localhost:8080/dobetterweb/dbw_tester.html

The diff is large. Can you confirm this is expected?

🙏

@@ -72,8 +72,10 @@ class DetailsRenderer {
* @return {!Element}
*/
_renderURL(text) {
const element = this._renderText(text);
const parsedURL = Util.parseURL(text.text);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're going to have to try to be backwards compatible here now that we've released

maybe we can make parseURL do this safely, accept {string|undefined} and return null if the URL was not parsable for some reason? then in here we can check if we were able to parse and either set the tooltip with the full text or fallback to the original behavior

on the plus side this should address both the linting and the test failures :)

@wardpeet
Copy link
Collaborator

thanks for the effort @johnboxall.

@patrickhulce wdyt? 😄

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! thanks for the work here @johnboxall!

@paulirish
Copy link
Member

Most good. Thanks @johnboxall !

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

Successfully merging this pull request may close these issues.

4 participants