3 ms·
I agree that often times CSS-in-JS forfeits some of the expressive power that makes CSS powerful, in the attempt to gain some muscle from JavaScript. Instead o
by err4nt 9y ago
I agree that often times CSS-in-JS forfeits some of the expressive power that makes CSS powerful, in the attempt to gain some muscle from JavaScript.
Instead of CSS-in-JS I think a better pattern for extending CSS with JavaScript is 'event-driven virtual stylesheets', which I call JS-in-CSS.
I'm writing a website dedicated to JS-in-CSS techniques, plugins, and theory. It's still a heavy WIP right now, but there are ~20 plugins that can be used and code samples and links to their documentation which is good to go already: http://responsive.style/ http://responsive.style/
I'm trying to write down and share the results of what I've found trying to combine JavaScript styling with CSS for years, and the patterns and techniques that make the two useful.
You should be able to take full advantage of 100% of CSS's expressive power _and_ still augment it with JavaScript logic. You can have the best of both, and this JS-in-CSS pattern works in every browser you can imagine (I recently got it working in IE7 and IE6 just for fun!(