Using LESS client-side

You need to download and add to your project less.js and call it from the HTML page:

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

Then, add the call to the .less file/s making sure you set the rel=”stylesheet/less”:

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

Tips:

– Make sure you call the styles before calling less.js
– When you link more than one .less stylesheet each of them is compiled independently. So any variables, mixins or namespaces you define in a stylesheet are not accessible in any other.

Options

You can set up some LESS options by using this code:

<script>
        less = {
            env: "development",
            logLevel: 2,
            async: false,
            fileAsync: false,
            poll: 1000,
            functions: {},
            dumpLineNumbers: "comments",
            relativeUrls: false,
            globalVars: {
                var1: '"string value"',
                var2: 'regular value'
            },
            rootpath: ":/Content/"
        };
    </script>

If you want to know more, check the LESS documentation.

Leave a Reply

Close Bitnami banner
Bitnami