Skip to content

Lighthouse: Preload key requests #179

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

Closed
primozs opened this issue Jul 2, 2019 · 8 comments
Closed

Lighthouse: Preload key requests #179

primozs opened this issue Jul 2, 2019 · 8 comments
Labels

Comments

@primozs
Copy link

primozs commented Jul 2, 2019

I hope its not too general question. Maybe somebody here knows how to solve css modules extract chunks with preload hint to the browser.

Screenshot 2019-07-02 at 19 48 20

@ScriptedAlchemy
Copy link
Collaborator

Do you use SSR?

@primozs
Copy link
Author

primozs commented Jul 2, 2019

Yes i use SSR.
babel-plugin-universal-import
webpack-flush-chunks
webpack

everything latest

@ScriptedAlchemy
Copy link
Collaborator

ScriptedAlchemy commented Jul 2, 2019

Okay, check out webpack flush chunks and pretty much flush out the files, then add a preload tag to them and insert it as a string in SSR.
add the reload links to your

const preloadTags = css.map(sheet=>{
return `<link rel="preload" href="${sheet}" as="style">`
})
preloadTags.join('')

@primozs
Copy link
Author

primozs commented Jul 3, 2019

Ok I thought there might be some other way, that this would be automatically provided for the right candidates to flush chunks.
Thank you Zack for the answer!
Cheers

@primozs primozs closed this as completed Jul 3, 2019
@primozs
Copy link
Author

primozs commented Jul 3, 2019

I must be doing something wrong, maybe my issue is similar to #125 but I don't know what was the solution there.

So I am checking the output of styles, stylesheets from flush chunks and the whole output looks like required and not a candidate for preload.

Later in the page load there is additional scripts and styles links loaded the ones visible in the screenshot that I posted.

Those styles are imported (required) in a component that is imported with universal import.

Example:

- some page (its one styles listed in flush chunks). All good until here.
  | - MapViewEdit component imported with universal component (these styles are loaded later). 

   These styles are not in flush chunks stylessheets array and it seams like candidates for preload.
const MapViewEdit = universal(
  import(
    /* webpackPreload: true */ 'seeyou-mapview/src/components/MapViewEdit'
  ),
  {
   ... conf props
  }

Is there a way to avoid this issue altogether?

@primozs primozs reopened this Jul 3, 2019
@primozs
Copy link
Author

primozs commented Jul 3, 2019

I guess it should not be be aliased path for universal import dependency.

@primozs primozs closed this as completed Jul 3, 2019
@seeruk
Copy link

seeruk commented Apr 17, 2020

@primozs Can you explain what you mean here? I've also run into this issue and am unsure about how to resolve it. It's exactly the scenario you've described where I have a page and it's chunks are in the flushChunks output, but it lazy loads something else and that isn't in there.

@primozs
Copy link
Author

primozs commented Apr 17, 2020

@seeruk Hi, I wish I could help but I really dont remember any more.

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

No branches or pull requests

3 participants