Can Enyo load file on demand?

Enyo loads all the .less file while refresh pages. That's of course a waste of resources.
Can Enyo load these files on demand?


  • The deploy script can fix that for you. It processes, concatenates and minifies your files, resulting in:

  • It's probably a good idea to check out the Bootplate. Some more information:
  • enyo.load() may be able to help you but it's pretty low level so you'll likely have some work to do to use it effectively. Here's some rather dated work I did with it but the concepts should still be applicable even if the code doesn't work (yymv there).
  • I found out that LESS wastes a lot of time to compile the .less files. How can I load the compiled "css" files rather than "less" files?
    I don't want to run the deploy script every time. I want to load the "css" files of Enyo, but my source code will be remain "less" files.
    I hope you can understand my poor English.
    Thank you very much.
  • You could include the compiled .css files in your package.js file(s), rather than the .less file. If you don't list the .less files in your package, enyo doesn't touch them.

    I'm using a custom build process to parse my less files before running enyo's own build script.
  • For the libraries, like onyx, you can alter your package.js to include the precompiled version.
      // instead of '$lib/onyx'
      // other libs and your app sources
    You can still use LESS for your sources or even other libs if need be.
  • Thanks bro, you are very helpful.
    Instead of your advice, I modified the package.js under onyx/css to:
    enyo.depends( //"onyx.less" "onyx.css" );

    Also the package.js under moonstone/css to:
    enyo.depends( "moonstone-light.css" );

    Is this correct?
  • And, How to insert beautiful source code ?
  • That works too. I had assumed you wanted to avoid updating the lib source directly but that's a pretty innocuous change.

    Not sure what you mean by your follow up question. If you don't wish to have the code minified during the build, you can pass the -B option to the deployment script which will beautify it.

    If you just want beautiful code to start with, choosing Enyo was a great choice! ;)
  • I mean, the source code in this forum.
    I insert the source code using "code" bracket, but it's quit ugly. How to insert source code like your beautiful source code?
  • @zhy1378 make sure to surround your source code with both the "pre" and the "code" tags, so that the whitespace is preserved.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!