Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally remove all class attributes #13

Open
Stranger6667 opened this issue Jun 21, 2020 · 2 comments
Open

Optionally remove all class attributes #13

Stranger6667 opened this issue Jun 21, 2020 · 2 comments

Comments

@Stranger6667
Copy link
Owner

Stranger6667 commented Jun 21, 2020

Problem

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.
@cossssmin
Copy link

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 🙈

@Stranger6667
Copy link
Owner Author

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants