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

Can Lighthouse Plugins specify URL query parameters #9754

Closed
t-kelly opened this issue Sep 28, 2019 · 3 comments
Closed

Can Lighthouse Plugins specify URL query parameters #9754

t-kelly opened this issue Sep 28, 2019 · 3 comments

Comments

@t-kelly
Copy link

t-kelly commented Sep 28, 2019

Summary
Want to expose additional HTML page attribution needed for Lighthouse plugin audits. Thought a query parameter would be the easiest way of triggering this. Can a Lighthouse Plugin:

a) Execute on an independent page load instance so these additional attribution doesn't impact other audits (e.g don't want additional HTML bytes to impact performance audits)?
b) Modify the input URL as needed (e.g. add query parameters)?

@connorjclark
Copy link
Collaborator

connorjclark commented Sep 28, 2019

You could define a new pass in your config, and have a gatherer run some JS to redirect the page. doing that in driver.evaluateScriptOnNewDocument on the beforePass should cause the page to load with your special query params before the browser spends much effort loading the page.

or, you could forget the extra pass, and just have your gatherer call fetch in page w/ the special query param.

If you want to use request headers instead, there's Network.setRequestInterception - but I would hold out on our abstraction over the Fetch domain (#9459).

@patrickhulce
Copy link
Collaborator

@connorjclark I think @t-kelly was hoping to do this in a plugin though, so the short answer is we do not plan on enabling plugins to do this outside of the fetch method Connor mentioned. A custom config would be required to add a new pass and a gatherer that modifies the pass url, which is just a simple beforePass that modifies the passContext.url to whatever you'd like (see https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/gatherers/http-redirect.js#L26 for an example)

@t-kelly
Copy link
Author

t-kelly commented Sep 30, 2019

I think @t-kelly was hoping to do this in a plugin though, so the short answer is we do not plan on enabling plugins to do this outside of the fetch method Connor mentioned.

This is true. And trying to stay away from custom configs so that using the plugin is as easy as specifying it/enabling it.

or, you could forget the extra pass, and just have your gatherer call fetch in page w/ the special query param.

I like this because it's simple and should work. The audits don't need to observe browser behaviour with this additional page attribution, just access specific page content which is totally achievable with an extra request.

Thanks all!

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

No branches or pull requests

3 participants