Skip to content
Jon Schlinkert edited this page Mar 23, 2013 · 2 revisions

Browser Options

You can set options by setting things on a global LESS object before the script:

<!-- set options before less.js script -->
<script>
  less = {
    env: "development",
    async: false,
    fileAsync: false,
    poll: 1000,
    functions: {},
    dumpLineNumbers: "comments",
    relativeUrls: false,
    rootpath: ":/a.com/"
  };
</script>
<script src="less.js"></script>

env

Type: String Default: development

Environment to run may be either development or production

async

Type: Boolean Default: false

Load imports asynchronously.

fileAsync

Type: Boolean Default: false

Load imports asynchronously when in a page under a file protocol.

poll

Type: Integer Default: 1000

The amount of time (in milliseconds) between polls while in watch mode.

functions

Type: object

User functions, keyed by name.

dumpLineNumers

Type: String Default: comments

Or "mediaQuery" or "all".

TODO: need more explaination here.

relativeUrls

Type: Boolean Default: false

Optionally adjust URL's to be relative. When false, URL's are already relative to the entry less file.

rootpath

Type: String Default: false

A path to add on to the start of every URL resource.

Watch mode

To enable Watch Mode, development mode must be enabled (less.env). Development mode is set automatically, based on whether the document's URL starts with file:// or localhost.

To get around this, use the following:

<script type="text/javascript">
var less = { env: "development" };
</script>
<script type="text/javascript" src="/lib/less-1.3.0.min.js"></script>

Note that the script must be run before the less.js file is included.

This manually puts Less in development mode, and enables watch mode.

More information

  • Usage: for an introduction to the language, please visit lesscss.org.
  • Developer info: visit the wiki homepage wiki

Clone this wiki locally