logoalt Hacker News

jamienk • today at 3:10 AM • 2 replies • view on HN

Still can't tree shake. It's what makes my old css files grow into monsters. I feel like everyone has given up on this.


Replies

robertwpearce • today at 3:55 AM

For small-scale projects, I use a server-side helper for an HTML page to include only certain CSS, SVG, and JS on a page. Each JS file is tiny, progressive, vanilla JS; SVGs are predefined and generate an SVG sprite that I then consume; CSS pulls in a `base.css`, the page's CSS file, and any component ones pull in their own. It's hand-rolled per project (pre-AI being decent), but I'm proud of it, and it keeps every page tiny. HTTP/2 multiplexing is pretty good and downloads the files more or less in parallel.

afavour • today at 3:13 AM

CSS modules ought to make it possible. But it’s more or less impossible with regular CSS, you have no idea when a class/ID might be used.