Blog About Contact

LessCSS available in Java and Wicket - less.js

Published Wed, 23 Jun 2010 • 8 comments

For the uninitiated, LessCSS is a powerful extension of CSS, that adds variables, mixins, operations and nested rules.

What this means is the ability to remove the repetition and redundancy which almost always pops up in CSS for complex web sites. Just the addition of variables is a god-send towards this, but other features like the addition of operations makes support each browser's "-moz-xxx" or "-webkit-xxx" properties, plus the standard ones go from 3+ lines to 1 line of CSS. This improves the signal-to-noise ratio of the CSS dramatically.

After having used LessCSS for a while now, I honestly wouldn't go back to using straight CSS again.

So... my problem was, how to use LessCSS in Java, and more specifically Wicket?

The author of LessCSS, cloudhead, wrote the initial version in Ruby, however the new and improved version of LessCSS is written in Javascript.

This makes integration quite easy, using Mozilla Rhino, a Java environment for running Javascript.

As part of the 0.3.2 release of visural-common I included an integration which Java-enabled less.js by using Mozilla Rhino. Asual also did this, however I had some problems with the way his version was initialised and shutdown when doing redeploys of a web app, so I wrote my own integration using the latest trunk version of less.js.

With the 0.6 release of visural-wicket, I created a Wicket Resource Provider which will do auto-compilation of ".less" files inside of Wicket web applications. This makes working with LessCSS as natural as working with CSS itself.

My only gripe with LessCSS at the moment is that it doesn't support the filter:IE.... garbage that you can use to do certain effects in IE browsers (e.g. gradients, shadows, etc.) which would be nice, however I know these are on the roadmap, and might be best separated out anyhow.

About the Author

Richard Nichols is an Australian software engineer with a passion for making things.

Follow him on twitter or subscribe by RSS or email.

You might also enjoy reading -

Discuss / Comment

There are 8 comments.

Add a comment

  • {{e.error}}

Thanks for your comment!/

Valid email address required.
Posting message, please wait...