Allow for Critical Css to be Configured via Layout Files #39406
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description (*)
This PR looks to move the critical css configuration to the layout configuration.
This allows for themes to more easily declare custom critical css files per layout type.
Theme authors can then write and set bespoke critical css targeting above the fold components for each page type (or generate them with external tooling).
The current approach is quite convoluted if I am not mistaken. Requiring you to declare a virtualType for the CriticalCss 'view model' and update the layout configuration to reference the new virtual type.
Manual testing scenarios (*)
css/critical-search.css
layout/catalogsearch_result_index.xml
Updating the
file_path
argument for thecritical_css_block
block.php bin/magento config:set dev/css/use_css_critical_path 1
php bin/magento cache:flush
<style [data-type="criticalCss"]>
node.<style [data-type="criticalCss"]>
node.Questions or comments
Contribution checklist (*)