Compile less on the interface

How can I compile more efficiently in a browser? I use this code to compile less in the browser, but it takes a lot of time to compile. I need to compile it in a browser not in the background.

<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> 
+8
css less
source share
1 answer

Actually your question is very wide. Why should you compile the client side of your code? What does the code look like? What, if any, changes when compiling the code again?

See also:

  • how to optimize less CSS? how to generate 1 smaller version of all less files? I also use modifyVars
  • Is it faster to precompile less?

In most cases, you should not use Less in the product environment. When you for some reason can try to optimize compilation time.

You are using env: "development" , this option prevents the cached code from being cached less. Each @import directive in your code requires a file that must be opened and read via http. Consider splitting your code into a static part (compile css) and a dynamic part that needs to be compiled for each request.

Update

Also see: https://github.com/less/less.js/issues/2339 if you use Safari:

You can re-enable chunking with {chunkInput: true} in the smaller parameters (or the data-chunk-input = "true" attribute on the smaller link).

+2
source share

All Articles