Why I Write CSS in JavaScript
11–20 of 255 posts
Re: Why I Write CSS in JavaScript
#12Re: Why I Write CSS in JavaScript
#13Author here, happy to respond to any questions. AMA!
How do you plan to accommodate NoScript users?
Re: Why I Write CSS in JavaScript
#14Re: Why I Write CSS in JavaScript
#15Earlier quoted context omitted.
How do you plan to accommodate NoScript users?
I know this will be unpopular, but after a certain point, noscript users just get a bad experience and that can't be helped. If a developer wants to provide a rich experience, then there will always be certain platform requirements. Without them, you will have a lacklustre experience. It's like saying "I want to have all the whizzy functionality of your app, but I want to access it using a standard, run of the mill,…
Re: Why I Write CSS in JavaScript
#16Author here, happy to respond to any questions. AMA!
Re: Why I Write CSS in JavaScript
#17Re: Why I Write CSS in JavaScript
#18Author here, happy to respond to any questions. AMA!
How do you plan to accommodate NoScript users?
It's rather easy too if you're using a (great) library like styled components - this functionality is built in and just works with a couple of extra lines of code.
The deeper question here is will the app work at all without JS. That's quite hard to achieve (every client side interaction must have a server rendered equivalent accessible via a url or url params, essentially) but the CSS part is easy.
Re: Why I Write CSS in JavaScript
#191- append only? No, each module/feature/widget gets its own CSS file, imported to the main app CSS file. Delete the widget? Delete the file.
2- Specificity issues? Never use IDs, stop using tag names and simple classes and adopt a simple naming structure (doesn't have to be BEM, it could literally be ".widgetName-header")
Since I adopted those 2, I've almost never had dead CSS from deleting features or collisions in my CSS. I do still have a small base set of styles that are shared but it's small enough to be easily manageable.
3- dynamic properties? CSS variables. Not an option? Child classes that apply the dynamic styles serve most use cases. Truly dynamic styles are rare, in my experience.
I'm still keeping an open mind about the possibilities, but my strong opinion (weakly held) is that I still don't see CSS-in-JS as more of a bandaid for people that like CSS and (for many, not all) those that don't have an in-depth understanding of it.
Re: Why I Write CSS in JavaScript
#20Author here, happy to respond to any questions. AMA!
How do you plan to accommodate NoScript users?