You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since everything is inlined, classes are useless and likely won't bring any benefits but occupy some space in the output. Hence I believe we can safely remove them.
Implementation
Add the keep_classes configuration option (everywhere, including CLI and all bindings). The default should be false.
Pass this config option down to the serializer and check it before writing classes to the output buffer here.
Reacted by Guiomar Valderrama, Zane, Jared Ellison and John L. Armstrong IV
Hi there, would it be feasible to just remove the selectors that have been successfully inlined instead? From both the CSS and the HTML class attrs - ideally you'd only want to purge selectors that you know have been inlined and are no longer needed.
This would solve a massive paint point for us in Maizzle too (selector matching and purging is limited by PostHTML capabilities, so we can't inline or remove some more complex selectors) and I think we could switch over from Juice 🙈
I think it is feasible + #265 notes a similar idea of keeping some subset of the original CSS.
The implementation does not look too complex - in this block, it is possible to track what selectors are applied and build a new CSS buffer from selectors without matches. I'm not sure if splitting those by the original source (right now it is an optimization to minimize allocations), but it could also be done. And some config option to enable this behavior will be also nice to have. I don't have much capacity to work on this myself right now, but will be happy to review a PR and provide any guidance needed.
P.S. Please, let me know if there is anything else that is missing in css-inline, so you can benefit from it :)
Activity
cossssmin commentedon Dec 30, 2024
Hi there, would it be feasible to just remove the selectors that have been successfully inlined instead? From both the CSS and the HTML
classattrs - ideally you'd only want to purge selectors that you know have been inlined and are no longer needed.This would solve a massive paint point for us in Maizzle too (selector matching and purging is limited by PostHTML capabilities, so we can't inline or remove some more complex selectors) and I think we could switch over from Juice 🙈
Stranger6667 commentedon Dec 31, 2024
Hi @cossssmin !
I think it is feasible + #265 notes a similar idea of keeping some subset of the original CSS.
The implementation does not look too complex - in this block, it is possible to track what selectors are applied and build a new CSS buffer from selectors without matches. I'm not sure if splitting those by the original source (right now it is an optimization to minimize allocations), but it could also be done. And some config option to enable this behavior will be also nice to have. I don't have much capacity to work on this myself right now, but will be happy to review a PR and provide any guidance needed.
P.S. Please, let me know if there is anything else that is missing in
css-inline, so you can benefit from it :)Stranger6667 commentedon Dec 29, 2025
Keeping only unused css is implemented in 0.19. I’ll make releases for all bindings today/tomorrow
Stranger6667 commentedon Mar 5, 2026
@dedupely class removal is not implemented - my comment above was strictly about css content, not about element attributes