-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Payload size implications #52
Comments
Twin doesn't handle any cross-component style de-duplication. I understand that your question needs to be asked as this is an important issue with CSS-in-JS. There's plenty of resource out there already that discuss these CSS-in-JS duplication issues. Also - I'd like to put together some resources on this as there's bound to be more questions on the topic in the future. |
A list of those resources would be great. We're just kicking off a project and considering all of our options. I agree that it's very hard to discuss without a real example. I imagine some sort of synthetic example may not be sufficient either. It also greatly depends on the size of the site. If twin were used only as a replacement for classnames (that is, the prop, not the template string), then it would be easy to swap out with the regular className prop so that things could be tested. That'd probably require a real site using it in exactly that way, so we may not get to that. Tailwind has its own problems even with purgecss of not really being amenable to code splitting, which means that every page has to ship the entire payload unless you do some additional critical css extraction. |
Closing up this issue now 👋 |
There's very little overhead with large amount of duplicated text if your output is being gzipped or compressed. Most everyone serves gzipped or brotli-ed assets including HTML anyway and CDNs can take care of it with little to no effort. So the additional complexity of de-duping during build time may not be worth the time or effort depending on how your delivery/distribution is setup. |
Hi there,
I really like the idea of twin.macro. I'm curious there if the ramifications to payload size have been considered at all. The nice thing about tailwind and other utility css frameworks is that you only have to pay the penalty of a utility class once, no matter how many times you use it. With twin.macro, it seems that the utility class is actually inlined everywhere it's used, which not only increases its size, but it also increases the number of css rules added to the dom.
I could see a macro adding the classes used directly and including the appropriate stylesheet, still obviating purgecss. That'd obviously not play nearly as well with Emotion, which is the whole point...
Anyway, just curious what thoughts have been had about this. Thanks!
The text was updated successfully, but these errors were encountered: