Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

X is to CSS what GWT is to Javascript; what is X?

Tags:

css

gwt

Is there a structured language for declaring styles in a sensible way, which can then be rendered into browser specific css files, similar to what GWT does to Javascript?

It would ideally be a language that supports variables, deals with browser quirks and differences (e.g. filter:alpha vs opacity), provides an intuitive syntax for common tasks such as centering, and has a way to express fallbacks for less capable browsers.

like image 944
ehnmark Avatar asked Dec 23 '22 13:12

ehnmark


2 Answers

Sass, as in Haml and Sass has some of what you're looking for. It has variables, math, and other goodies.

The official version is Ruby based, but there are versions for other languages like PHP and Python.

It might not do EVERTHING you mentioned, but it's worth checking out.

like image 140
nicholaides Avatar answered Jan 01 '23 03:01

nicholaides


GWT's ability to generate code on the fly and it's powerful "deferred binding" capability could definately be applied to stylesheets and allow for build-time optimization of CSS.

Right now, the "GWT way", according to styles is to include all the styles you'll need and use apply them by making use of "dependent style names". But this definitely leads to lost of useless CSS being included where it's not needed.

I know there is at least one attempt to optimize CSS at build time. This would involve combining multiple seperate stylesheets into one, and removing all non-essential whitespace (minifying). I think this might also allow you to make use of deffrred binding to essentially "optimize out" CSS from where it's not needed (ex: browser specific styles).

StyleInjector

like image 40
Mark Renouf Avatar answered Jan 01 '23 02:01

Mark Renouf