Path

ez projects / ezjscore / forum / general / ezjscore loads external yui...


ezjscore loads external yui2 js on yahoo CDN (CDN disabled)

You need to be logged in to post messages in the forums. New users may register here.

Jerome Despatis

Member since:
11 November 2008

Posts: 20

Tuesday 25 January 2011 2:23:18 pm

Hi,

I use the default settings of ezjscore, with a brand new ezp 4.4
With default settings which is disable CDN.

I have installed ezfind that uses autocomplete and new nice features,

However on my website, ezjscore loads external .js from the CDN, instead of getting them locally (which I prefer).
Here are the files retrieved on yahoo:

http://yui.yahooapis.com/2in3.1/2...i2-connection/yui2-connection-min.js
http://yui.yahooapis.com/2in3.1/2...utocomplete/yui2-autocomplete-min.js
http://yui.yahooapis.com/2in3.1/2...m/yui2-skin-sam-autocomplete-min.css
http://yui.yahooapis.com/2in3.1/2.8.0/build/yui2-yahoo/yui2-yahoo-min.js
http://yui.yahooapis.com/2in3.1/2.8.0/build/yui2-event/yui2-event-min.js
http://yui.yahooapis.com/2in3.1/2.8.0/build/yui2-dom/yui2-dom-min.js
http://yui.yahooapis.com/2in3.1/2...i2-datasource/yui2-datasource-min.js

However i can see some of these js files in extension/ezjscore/design/standard/lib/yui/2.8.1/build:
extension/ezjscore/design/standard/lib/yui/2.8.1/build/connection/connection-min.js
extension/ezjscore/design/standard/lib/yui/2.8.1/build/autocomplete/autocomplete-min.js
etc...

the files have different names, but I really think they can be used instead of files on the CDN

=> maybe it comes from the fact ezjscore uses 2.8.1, but loader everywhere contains 2.8.0 ? (however a symlink from 2.8.0 to 2.8.1 does nothing)
=> maybe ezfind has to change something ? for instance, it loads yui2-connection, this way:
YUI(YUI3_config).use('yui2-connection', 'yui2-autocomplete', function (Y) {
YAHOO = Y.YUI2;
initAutosuggest();
});

Any idea is welcome
Up

André R.

Member since:
14 January 2008

Posts: 170

Wednesday 26 January 2011 11:05:55 am

Haven't tested this yet, but from looking at the 2in3 page it looks like something like the following might help:




diff --git a/classes/ezjscserverfunctionsjs.php b/classes/ezjscserverfunctionsjs.php


index a30bdd4edaecb11d669d2ccb34b6ce3364abf106..2321c40e248fcafd05d83928ec60e14d4345a572 100644


--- a/classes/ezjscserverfunctionsjs.php


+++ b/classes/ezjscserverfunctionsjs.php


@@ -112,7 +112,7 @@ class ezjscServerFunctionsJs extends ezjscServerFunctions


        {


            $scriptFiles = $ezjscoreIni->variable( 'eZJSCore', 'LocalScripts' );


            $scriptBases = $ezjscoreIni->variable( 'eZJSCore', 'LocalScriptBasePath' );


-           $packerFiles = array_merge( array( $scriptFiles['yui3'], 'ezjsc::yui3conf::' . $scriptBases['yui3'] ), $packerFiles );


+           $packerFiles = array_merge( array( $scriptFiles['yui3'], "ezjsc::yui3conf::{$scriptBases['yui3']}::{$scriptBases['yui2']}" ), $packerFiles );


        }


        return '';


    }


@@ -120,13 +120,16 @@ class ezjscServerFunctionsJs extends ezjscServerFunctions


    /**


     * Yui3 config as requested by {@link ezjscServerFunctionsJs::yui3()}


     *


-    * @param array $args First value is base bath if set


+    * @param array $args First value is base path for yui3 and yui2 (for yui 2in3 setup)


     * @return string YUI 3.0 JavaScript config string


     */


    public static function yui3conf( $args )


    {


-       if ( isset( $args[0] ) )


-           return 'var YUI3_config = { \'base\' : \'' . self::getDesignFile( $args[0] ) . '\', modules: {} };';


+       if ( isset( $args[1] ) )


+       {


+           return "var YUI3_config = { 'base': '" . self::getDesignFile( $args[0] ) . "', 'modules': {}," .


+                  " 'groups': { 'yui2': { 'base': '" . self::getDesignFile( $args[1] ) . "' } } };";


+       }


 

        return 'var YUI3_config = { modules: {} };';


    }




Or stop using yui2 in yui3 now that yui3 includes AutoComplete widget(even thoug it's in beta).


2in3 page: https://github.com/yui/2in3

Lead Engineer eZ Publish
@: http://twitter.com/andrerom

Up

Jerome Despatis

Member since:
11 November 2008

Posts: 20

Wednesday 26 January 2011 3:28:32 pm

Thanks for your patch André R,

I've successfully tested it ! no more http connections to yahoo, it can speed up a little more my website now, cool !

I've added a bug on this:
http://issues.ez.no/IssueView.php?Id=17877

Maybe you can import your patch and close this ticket ?

Thanks again...
Up

Jerome Despatis

Member since:
11 November 2008

Posts: 20

Wednesday 26 January 2011 3:44:45 pm

I was wrong indeed, the patch doesn't work well

I get a js error (but not all times, really strange...)
error is: YAHOO is undefined on line var dsJSON = new YAHOO.util.DataSource(_cfg.url);
Up

André R.

Member since:
14 January 2008

Posts: 170

Wednesday 26 January 2011 10:33:20 pm

Ok, guess we need to look more into it then.
Could the error be from the fact that you tried to load dojo.js with ezscript_load maybe? (but I guess you should have been getting other errors then)

Lead Engineer eZ Publish
@: http://twitter.com/andrerom

Up

Jerome Despatis

Member since:
11 November 2008

Posts: 20

Thursday 27 January 2011 12:44:59 pm

All my tries to load dojo with ezjscript have gone wrong.. so I keep on loading dojo with a <script> tag

dojo is not involved in the problem explained here (really don't think so)

Up

You need to be logged in to post messages in the forums. New users may register here.