22 ms·
Very creative! Would have to try this to see how much sense it makes - there must be a slight performance degradation because the content of the style tags can'
by moritzwarhier 3y ago
Very creative! Would have to try this to see how much sense it makes - there must be a slight performance degradation because the content of the style tags can't be applied and parsed immediately, no?
So that's a fundamental difference, no build step, tiny JS runtime instead that hooks into the page rendering.
The concept is interesting.
Has the benefit of staying close to vanilla CSS syntax.
I'm curious why you chose 'me' or 'this' instead of '&'?
OTOH, it might be useful for the browser to consider the style tags as valid but with unknown element names (that are also forbidden for custom elements as they don't have a dash). Don't know if this would be possible using '&' and it also collides with the CSS nesting proposal.
So.. after all, nice idea!
Being a bit more cynical though, I'm not sure if the JS dependeny and performance implications would be worth it for me to use in actual projects.
Tailwind has the benefit of producing lean CSS files with 0% dead CSS.
This approach would be more prone to the usual issues with CSS I guess, but addding custom syntax anyway. I'm also sceptical of transpiling to CSS using JS on the client.
- yodon 3y ago> I'm curious why [the author] chose 'me' or 'this' instead of '&'? Looking at the source, the parser is written to let you use any of "me", "this", or "self" (I'm guessing you spotted that). If I have one quibble with this project it's that line. The multiplicity of "this" designators is going to make client code written for this library harder to read not easier. IMO the author should just pick one and stick with it, and do it now before there are too many pages using it. This is a false "flexibility" that feels like the bad old days when people thought "browsers should be flexible in what they accept", which did not serve us well in the long run. That said, this is brilliant work.