0

Configuration to load YUI locally

Hi,
From what I understand the default behaviour for Mojito to load YUI
(on client side?) is to use combo loader from yahooapis:
http://yui.yahooapis.com/combo?3.4.1/build/yui/yui-debug.js&3.4.1/build/yui-base/yui-base-debug.js&3.4.1/build/oop/oop-debug.js&3.4.1/build/event-custom-base/event-custom-base-debug.js.....
etc

But for whatever reason sometimes I find (from the firebug network
panel) that the connection has failed (timed out) when the above
request was sent.
So my question is how do I configure Mojito to load YUI from local
directory instead?
I followed the documentation to include the following yui config in
application.json:
   "settings": [ "master" ],
   "yui": {
     "showConsoleInClient": false,
     "config": {
        "fetchCSS": false,
        "combine": true,
        "comboBase": 'http://mydomain.com/combo?',
        "root": 'yui3/'
      }
   },
But this does not seem to do anything, I still see the request sent to
yui.yahooapis.com. I even tried just setting combine:false but still
it was sending out combo string.
If the above attempt to set yui directory failed, will it generate any
error message?
Also where in my Mojito project should I store this yui directory and
how can I reference to it from Mojito (/static/??) ?
Any help would be greatly appreciated, thanks!

by
2 Replies
  • I have a solution.

    In mojito module (0.3.27-0.3.28 tested)
    -for local install of mojito:
    /node_modules/mojito/lib/app/autoload/loader.common.js
    -for global install of mojito:
    /usr/local/lib/node_modules/mojito/lib/app/autoload/loader.common.js
    at line 157:
    instead of
    combo.js = this._createURLlist(loader.comboBase, comboJsParts);
    put
    combo.js = this._createURLlist(this.appConfig.yui.comboBase || loader.comboBase, comboJsParts);
    at line 158:
    instead of
    combo.css = this._createURLlist(loader.comboBase, comboCssParts);
    put
    combo.css = this._createURLlist(this.appConfig.yui.comboBase || loader.comboBase, comboCssParts);
    and then put

            "yui": {
                "comboBase": "/yui/combo?"
            }

    into application.json

    it works well for me, with second server on node.js that serves combined yui urls - but if you want - they can be merged simply.

    For serving combined yui - try combohandler:
    https://github.com/rgrove/combohandler
    or
    npm install combohandler
    nice tool to combine js and css - works with yui - sample exists on github. you can integrate it via middleware, and mojito server will serve yui (but it seems for me, that dedicated server for yui combining is a good practice - it tooks pretty much time to process request)
    0
  • Alexey:
    Thanks for helping out! We really appreciate it.
    Your patch would make a great pull request, and we can incorporate it into the Mojito tree.
    Would you like to submit one? Here is how to get started:
    https://github.com/yahoo/mojito/wiki/Contributing-Code-to-Mojito

    0

Recent Posts

in Yahoo! Mojito