### Problem/Motivation

Stylify currently attaches saved CSS through `html_head` as inline
`

` (and similar) tags. In a typical theme, `html_head` is printed by `head-placeholder`, which appears *before* `css-placeholder`. Theme CSS such as `style.css` / `style1.css` is printed later. Because of cascade order, Stylify rules lose to equal-specificity theme rules. Example: - Stylify: `body.node-9 header#header { position: absolute; z-index: 9999; }` - Theme CSS loads after the Stylify `` tag, so the override does not apply. A second issue appears when logged in: Toolbar / BigPipe can invoke the CSS renderer more than once. Duplicate Stylify CSS can leak into page markup and show as visible text (including near the toolbar / Logout link).
CommentFileSizeAuthor
#4 error1.PNG17.52 KBangel_devoeted

Issue fork stylify-3618045

Command icon 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

shardashukla created an issue. See original summary.

shardashukla’s picture

Status: Active » Needs review
angel_devoeted’s picture

StatusFileSize
new17.52 KB

Tested MR !2 and ran into a PHP fatal error (Class "Drupal\stylify\Asset\StylifyCssCollectionRenderer" not found) upon loading the page. It looks like the StylifyCssCollectionRenderer.php class referenced in stylify.services.yml might not have been committed to the branch yet.
Also, could we consider refactoring the static property $pageStylesheets in StylesheetAttachmentBuilder to avoid keeping static state in a service across requests?

error

harjyottkaurr’s picture

working on this

harjyottkaurr’s picture

Assigned: harjyottkaurr » Unassigned
Status: Needs review » Reviewed & tested by the community

I have tested this, working as expected.