The module currently does not provide a global Critical CSS configuration to act as a fallback
when no contextual match is found. To improve the initial experience and avoid manual setup,
a default Critical CSS option managed via simple config is needed.
Key Technical Points
- Create a simple configuration object:
critical_css_ui.settings. - Add the
default_critical_csskey to store the global CSS fallback. - Add a boolean
default_enabledto toggle the fallback on or off. - Provide an initial configuration file inside
config/install. - Create a configuration schema in
config/schema/critical_css_ui.schema.yml. - Expose an admin settings form to edit the default Critical CSS configuration.
- Integrate the fallback into the resolution logic:
node:ID → node:bundle → default. - Invalidate caches whenever the configuration is updated.
Issue fork critical_css_ui-3558158
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
diegodz commentedComment #3
diegodz commentedComment #5
sergeydruua commentedImplemented the default Critical CSS configuration logic as requested. Changes include: Updated schema and install config to support default_enabled and default_critical_css. Updated CriticalCssConfigForm to include the new fields with #states visibility. Refactored CriticalCssConfigForm to use Dependency Injection properly. Updated CriticalCssProvider::getCriticalCss() to fallback to the default configuration if no context match is found. Tested manually and verified that the fallback CSS is applied when expected.
Comment #6
diegodz commentedHi @sergeydruua,
Thank you for your contribution. I’ll review the MR as soon as I have some available time and will merge it into the 1.0.x branch.
Thanks again for your support!
Comment #7
diegodz commentedComment #9
diegodz commentedComment #11
diegodz commentedComment #13
diegodz commented