YUI modules in yui_modules folder are attached even if not required or used

Hi bartenders,

My yui modules in the yui_folder are attached (the function fn in YUI.add(name, fn) is executed ) even if I do not use (YUI().use) or require (requires:[...]) them.

If one put toto.js in yui_modules:

  YUI.add('toto', function(Y, NAME) {
    Y.log('Hello', 'WARN', NAME); 

You will see the 'Hello' when starting mojito even if nobody uses toto.

Is there a way of avoiding that?

It is maybe related to https://github.com/yahoo/mojito/issues/53

2 Replies
  • @Dodo, yes, on the server, everything that is available with common or server affinity will be attached when the server boots. This is a provision to improve performance by not having to attach modules when needed in a controlled environment like the server. Usually, those YUI Modules will define things, instead of automatically carry on with an operation.

    I want to learn more about your use-case, what exactly does the YUI Module is trying to do that it can't be automatically attached?

  • @caridy thanks for the answer.

    It is not really a use-case, I just noticed that when experimenting with a mongodbCRUDMojit. I was creating a mongoose schema in an old unused module (bad) and creating again the same schema in a mojit model. I'll follow your advice and will only define things in YUI modules. Thanks again.


Recent Posts

in Yahoo! Mojito