-
Notifications
You must be signed in to change notification settings - Fork 1.5k
What is the best way to preload my chunked CSS? #2125
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
Comments
Luckily, I think you may have just misread the version. Funny you should ask today, we are currently looking into the CSS/font/image aspect this in #2124. Hopefully, we can ship this feature for styles soon. |
Lol, oops, I was reading that as 4.3.3. |
No problem, feel free to chime in on the other issue with your use-case. |
Sure thing. I just need to get it working first. I'm creating the chunk like this: const BelowFold = () => import(
'./below-fold.vue'
/* webpackChunkName: "below-fold" */
); Which works as expected. However, when I change that to: const BelowFold = () => import(
'./below-fold.vue'
/* webpackPreload: true */
/* webpackChunkName: "below-fold" */
); Google PageSpeed Insights still complains that I should preload Do have any idea where I'm going wrong? (Sorry, I know this likely isn't a webpacker issue, so I can head off to StackOverflow if you'd rather). |
I think we can use <link href="<%= Webpacker.manifest.lookup('below-fold-chunk.css') %>" rel="preload" as="style"> Can you do me a favor? Could you post your generated |
Sure.
|
Thats what I thought. (the chunk bit is from webpack) This should work: <link href="<%= Webpacker.manifest.lookup('below-fold.css') %>" rel="preload" as="style"> becomes 👇 <link href="/packs/css/below-fold-a5c67fb7.chunk.css" rel="preload" as="style"> Tell me how that works. (also, test out with fonts) |
Oh yeah, that completely solved the problem. Thank you very much indeed!
The fonts are being pulled in by Semantic UI. Should I go through and add a similar line for each font? |
Ok, ta. I'll look into that tomorrow. Thanks once again for your help. |
I am not too familiar with Semantic UI, but I would assume so since they are in your manifest. |
I'm currently running my Rails/Vue app through Google's PageSpeed Insights and it's telling me I could shave off a reasonable amount of time (on mobile) if I preload my chunked CSS.
It says:
It seems webpack 4.6.0 adds support for preloading using a magic comment:
However, the latest version of webpacker uses webpack 4.33.
What is the best way to implement this using the current version of webpacker? I'd be grateful for a pointer in the right direction.
The text was updated successfully, but these errors were encountered: