Needs review
Project:
Critical CSS UI
Version:
1.0.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
17 Nov 2025 at 12:35 UTC
Updated:
27 Nov 2025 at 10:44 UTC
Jump to comment: Most recent
The module currently provides a plain textarea for editing Critical CSS.
To improve the editing experience and reduce user errors, the form should integrate a code editor
with syntax highlighting and basic linting.
critical_css_ui.libraries.yml.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 commentedI was considering integrating a CSS validator, specifically using CodeMirror. However, I ran into several problems. Since critical CSS is often reduced to a single line, the validator doesn't parse it correctly. It also doesn't recognize some `--webkit` rules necessary for browser compatibility.
Therefore, the integration generates false positives and blocks valid CSS.
This task will only cover the syntax highlighting integration; we'll leave the validator for a future project and release a beta version with this feature.
Comment #4
sergeydruua commentedIntegrated CodeMirror for syntax highlighting. Implementation details: Added critical_css_ui.libraries.yml using CDN version of CodeMirror (to keep the module lightweight as requested). Added js/critical-css-editor.js to initialize the editor on specific textareas. Implemented hook_form_alter in .module file to attach the library and class to the Config form and Entity forms. No validation implemented in this step (syntax highlighting only). Tested manually: Textareas are correctly converted to CodeMirror instances with CSS mode enabled.