5 ms·
What problem is this trying to solve? I don't see what benefit there is to generating a unique CSS class for each individual style; it just seems like a reimple
by supernintendo 8y ago
What problem is this trying to solve? I don't see what benefit there is to generating a unique CSS class for each individual style; it just seems like a reimplementation of inline styles.
In addition to that with atomic CSS your application bundle size grows, i.e., at some point, you can keep adding CSS, but the file size of your CSS bundle won't change (increase).
It should be noted that this is absolutely not true if your application uses static rendering. Sure, you might be able to avoid multiple references to the same CSS rule in your stylesheet but now your compiled HTML is even more bloated. A button from any given CSS framework takes 5-12 CSS rules to look decent. Now imagine creating a unique class name for each rule and applying that to every button on the page.
There's also the issue of swapping styles in the browser to get a sense of how things look. I maintain an internal admin UI where the navbar is styled differently depending on the environment to avoid a developer accidentally affecting production data. It's a lot easier to swap `.dev` with `.prod` on an element than it is to swap out all of these class names or restart my web server, overriding the environment. DSS also means that your developers will have to sift through a lot of useless noise when inspecting the DOM; pull up https://dss-lang.com/ https://dss-lang.com/ in your browser's DOM inspector and tell me if that's something you'd enjoy working with.
- TheDong 8y agoIndeed, there's no way this reduces total size of the full content delivered to a user's browser. The full style for a button on that page is: DSS-6s7ra7ruauhgs1p418889953wr DSS-7ntue76nuangdx9rpn9qj5qt1r dss_zwfkme-4y1s1i dss_1l2fjdf-4y1s1i dss_18pw31d-kb7nvz dss_1i43vt4-kb7nvz dss_14e3233-fkmc3a dss_1uacqdt-m23pbg dss_hsg9lc-6hioi1 dss_17gxg2d-3b2xjc dss_2w3qqg-kpf7b0 dss_17ivt7s-6r0uxk dss_1aj8hfn-iu2jf4 dss_itsfbh-kb7nvz dss_rfc3hq-1jm7nmq dss_36r1g7-t94yts dss_5b4my1-18gtugd dss_1cskmy3-6r0uxk dss_1gss4ms-t94yts dss_1496ft4-t94yts dss_ik5ixr-t94yts dss_nmh4m5-t94yts dss_28mnjz-t94yts dss_1mkfkum-t94yts dss_xa3mwb-t94yts dss_1j1jkdq-t94yts dss_gbyv8j-iu2jf4 dss_1sgye3s-x2w3rg dss_1yzcwad-x2w3rg dss_py4k60-iu2jf4 dss_1q9w8i1-irswps dss_rwa454-4clis7 dss_1ot5qnt-1dvrs12 dss_1bix7jo-1v6z61t dss_107cujk-1v6z61t dss_19r5tdc-1v6z61t dss_ez733i-1v6z61t dss_igbmbv-kb7nvz dss_1qu7vtx-kb7nvz dss_1swntt0-kb7nvz dss_1x63vd7-kb7nvz
- ggurgone 8y ago> it just seems like a reimplementation of inline styles. In a way it is but with some important differences: - You still write styles in regular files instead of inline. You then reference those in your templates and the library replaces them with the corresponding atomic CSS classes. - See my reply to CGamesPlay. > with atomic CSS your application bundle size grows, i.e., at some point your application bundle size grows "logarithmically"! Probably "logarithmically" got accidentally deleted. In a way CSS is an "append only" language (or at least that's how it ends up being used) and the more features you add the more your bundles grow. With atomic CSS classes this is not an issue. > A button from any given CSS framework takes 5-12 CSS rules to look decent. Now imagine creating a unique class name for each rule and applying that to every button on the page. Just to make sure that it is clear enough, you as developer don't generate/apply unique classes by hand. Instead you reference rules which map to sets of atomic classes. > HTML is even more bloated True, but I believe that this approach is fairly gzip friendly. So repetition is not an issue. > There's also the issue of swapping styles in the browser to get a sense of how things look. Controlling things globally could be handy but it won't scale. I don't think that it is a deal breaker to toggle some state in your app and hit refresh. > DSS also means that your developers will have to sift through a lot of useless noise when inspecting the DOM DSS already allows to include readable class names and I am planning to use those to add source maps. - All your concerns and comments are valid however atomic CSS has its benefits (companies like Linkedin, Facebook and Twitter use solutions that compile to those kind of classes). The main feature of DSS is deterministic styles resolution anyway, atomic CSS classes are only the medium to achieve that with plain old static CSS.
- deleted 8y ago[deleted]
- supernintendo 8y agoTrue, but I believe that this approach is fairly gzip friendly. So repetition is not an issue. Ok, that's true. But what about browser caching? Using traditional CSS, users only have to visit one page and they've downloaded the stylesheet for the entire site. They can navigate to 100 other pages and never have to re-download the stylesheet because it's cached. With DSS, our CSS files are smaller but our HTML bodies are larger due to all of these class names. That means every time we load a new page, we're downloading thousands of bytes of class names that we already have. For static rendering this is a no-go, regardless of gzip. Controlling things globally could be handy but it won't scale. I don't think that it is a deal breaker to toggle some state in your app and hit refresh. It's a deal breaker for me because my designer doesn't know Elixir. You act like toggling "some state" within an application is trivial. Maybe it is to you or me but it might not be to one of your team members who is only concerned with the CSS. I don't know what you mean by "won't scale". We're talking about changing styles in the browser. This is a developer workflow issue, not a technical issue. The main feature of DSS is deterministic styles resolution anyway, atomic CSS classes are only the medium to achieve that with plain old static CSS. Not true. There's another way to achieve that: good CSS.