a blog for those who code

Wednesday 16 July 2014

Overview of Less.js

Have you heard of Less.js? Yes, Great! No, Not a problem...We will be discussing about Less.js in this post.
According to lesscss.org : "Less is a CSS pre-processor, meaning that it extends the CSS language, adding features that allow variables, mixins, functions and many other techniques that allow you to make CSS that is more maintainable, themable and extendable."

Lets get deep into Less. It runs inside Node (must be really fast then), in the browser and inside Rhino. It can be used on the command line via npm, at first you have to install Less via npm.

$ npm install -g less

Usage in Code

var less = require('less');
less.render('.class {height : 5}'), function(e, css) {
console.log(css);
});

which will give output as

.class {
    height:5;
}

Usage in Client-Side

<link rel="stylesheet/less" type="text/css" href="yourStyles.less"/>

Then add less into <script> tag.

<script src="less.js" type="text/javascript"></script>

This post is just to make you aware of using Less in code. You can check more here.
Please Like and Share the Blog, if you find it interesting and helpful.

1 comment: