How can i compile less in efficiently on the browser? I'm using this code to compile less on the browser but this is taking very long time in compilation. I need to compile it on the browser not in back-end.
<script>
less = {
env: "development",
logLevel: 2,
async: false,
fileAsync: false,
poll: 1000,
functions: {},
dumpLineNumbers: "comments",
relativeUrls: false
};
</script>
<script src="http://cdn.storehippo.com/assets/less-1.5.0.js"></script>
<script src="lessfile.less"></script>
Pre-compiling LESS into CSS: To compile LESS into CSS, we use the below command in a command prompt. The lessc command lets us precompile our LESS file into a basic CSS file. This helps us in writing modular code using LESS programming and still getting all the benefits of CSS by compiling it into traditional fast CSS.
Less (which stands for Leaner Style Sheets) is a backwards-compatible language extension for CSS. This is the official documentation for Less, the language and Less.js, the JavaScript tool that converts your Less styles to CSS styles. Because Less looks just like CSS, learning it is a breeze.
Create a stylesheet with . less extension and link it in your document using the rel="stylesheet/less" attribute. You are all set and can compose styles within the . less .
css file nested under it in Solution Explorer after being enabled on the project. By default, compilation is off and that's indicated by a watermark at the bottom right corner of any LESS file. To enable LESS compilation, simply click the watermark and it changes to indicate LESS compilation is "on". All .
In fact your question is very broad. Why do you have to compile your code client side? How does you code look? What, if any, changes when you compile you code again?
See also:
In most cases you should not use Less in a product environment. When you do for some reason you can try to optimize compile time.
You are using env: "development"
, that option prevent Less from caching the compiled code.
Every @import directive in your code requires an file that has to be open and read over http.
Consider to split your code into a static part (compile css) and dynamic part that have to be compiled for every request.
update
Also see: https://github.com/less/less.js/issues/2339 if your are using Safari:
You can re-enable chunking with {chunkInput: true} in the less options (or data-chunk-input="true" attribute on the less link).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With