Open Leland opened 4 years ago
Hi @Leland. Thank you for your report. To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, please, review the Magento Contributor Assistant documentation.
Please, add a comment to assign the issue: @magento I am working on this
Hi @engcom-Alfa. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
The issue is still reproducible on fresh 2.4-develop
Preconditions:
bin/magento config:set dev/css/use_css_critical_path 1
);Manual testing scenario:
Go to Storefront -> Men category (for example);
Actual Result: :heavy_multiplication_x:
Compare to the final loaded result:
:white_check_mark: Confirmed by @engcom-Alfa
Thank you for verifying the issue. Based on the provided information internal tickets MC-40520
were created
Issue Available: @engcom-Alfa, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
@magento give me 2.4-develop instance
Hi @mrtuvn. Thank you for your request. I'm working on Magento instance for you.
Hi @mrtuvn, here is your Magento Instance: https://b059cf801e5e47fd4ebfc068b3d0179e-2-4-develop.instances.magento-community.engineering Admin access: https://b059cf801e5e47fd4ebfc068b3d0179e-2-4-develop.instances.magento-community.engineering/admin_fb68 Login: b451eebb Password: 1c9f51794a7b
Yes, there are other things that could be moved off the critical path. That doesn't mean that critical CSS is pointless though, and, besides, this issue is about the fact that the critical CSS in Luma is not good. This repo should have an example of a really well-made critical CSS file.
Seem we need extra workaround with critical for magento luma. From the docs guide i see some approach with penthouse but I'm not sure which is correct way https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/css-topics/css-critical-path.html (docs not write-well and not much information) Just wonder is there any correct way out there automatic generate css without manually approach
I do not remember exactly what tool was used to create critical path css for Luma theme. Probably it was either https://www.npmjs.com/package/critical or https://www.npmjs.com/package/penthouse. Or even https://www.sitelocity.com/critical-path-css-generator But I remember that generated critical path needed to be refactored as well because of some layout problems in generated css.
Here is my infor related with this problem. Which mean css critical need extra effort workaround (not well-written). Probably we miss some styles critical at the point of view FE, need for early stage above the fold Now i realised why we don't have critical default for blank theme :) Leave it's responsibility for FE devs
For this issue, we could even handwrite some manual critical CSS just as an example.
In my org, we are using Penthouse to generate the critical CSS, however. It would be an awesome thing to create a Grunt task that handles this, though that's totally unnecessary to just close this issue!
Please note that critical.css file probably should contain critical css both for mobile, tablet and desktop, otherwise it will be too jumpy during page load
For this issue, we could even handwrite some manual critical CSS just as an example.
In my org, we are using Penthouse to generate the critical CSS, however. It would be an awesome thing to create a Grunt task that handles this, though that's totally unnecessary to just close this issue!
Can you share your Penthouse setup in Magento 2?
@roman-mer sure - we're using Azure to handle deployments. We built a Penthouse node script that runs during the deployment that crawls through a headless Chrome instance and visits a specified number of URLs (homepage, PDP, etc). We then have some Regex that removes selectors that match to reduce the overall size. And finally, we have some manual CSS that is appended to it, which then produces a single critical.css file. It's very much in alpha state (and proprietary) so no code to share, sadly.
Someone might share a Penthouse setup in Grunt (Magento 2) I found such a customization recommendation, but so far I have not been able to implement it:
add new task grunt.initConfig({ penthouse: { extract : { outfile : '.tmp/out.css', css : './dist/css/full.css', url : 'http://localhost:9000', width : 1300, height : 900, skipErrors : false // this is the default }, }, });
i think there are not common results for all here. You have to build with your own tools to meet your requirements Build process deploy like Leland describe above. Css will change not only by the page you visit but also the viewport related (width height). Height 200 will be difference with Height 900. You need hand-on at output generated file for some improvements Default luma critical would not much help for you since styles quite big with we have alot styles and merged to 2 files (styles-l, styles-m). Almost of them (90%) is not all you need for specific page
For improve performance overall in m2 not just need from css side but also need improve from js too
@Leland Can you share how big size of your critical.css in your org? My site generate css critical file around ~ 300KB It's extremely big for single critical is it? My ideally it's should size around 20-30KB
@mrtuvn depends on the site. For this issue, I'd recommend staying in the 15-50kb range, however. Increasing every page's document size by 300kb will cause Luma's First Contentful Paint time to increase significantly.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!
This is a confirmed issue, and should not ever be marked stale IMO… perhaps stale bot’s settings should be tweaked?
Hi @Leland https://github.com/magento/magento2/pull/33084/files we already have PR for such case @ihor-sviziev should we add exempt labels also for confirmed
@mrtuvn let's discuss it with other maintainers
Preconditions (*)
Magento >2.3.4 Magento 2.4-develop
Steps to reproduce (*)
bin/magento config:set dev/css/use_css_critical_path 1
Expected result (*)
Actual result (*)
All told, here is what the default critical CSS experience on Magento 2.3.5's Luma looks like:
Compare to the final loaded result:
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.