Loading ...
Sorry, an error occurred while loading the content.

YUI Loader (a problem: why should I use it?)

Expand Messages
  • renatoiwa
    Hey guys, I m enjoying the YUI 3.x but there s something that is annoying me and that s one of the main reasons I believe it will be a problem for everyone who
    Message 1 of 4 , Apr 1, 2009
    • 0 Attachment
      Hey guys,

      I'm enjoying the YUI 3.x but there's something that is annoying me and that's one of the main reasons I believe it will be a problem for everyone who will use the YUI with loader...

      So, here's the problem.

      If I understood correctly, we MUST run commands under this syntax:

      YUI.use("node"),function(Y){
      // COMMANDS
      });

      I know we have the option to load components through the traditional process by adding the components to the requests of the page and then using:

      YUI.use("*"),function(Y){
      });

      Ok, but I really want to use the load method.
      YUI uses the benefit of combo handler. But what I think it will be a problem is that combo handler doesn't have control of caching the files because the URL will always be changing, as it is dynamic and LOADER does not check if I already have requested a component or not.

      Let me give you guys a very simple example:

      <script type="text/javascript">
      YUI().use("json",function(Y){
      Y.log("Test 1");
      });

      YUI().use("json","node",function(Y){
      Y.log("Test 2");
      });
      </script>

      And here's what YUI will request dynamically:

      <script id="yui__dyn_0" type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/combo?3.0.0pr2/build/json/json-min.js"/>

      <script id="yui__dyn_0" type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/combo?3.0.0pr2/build/json/json-min.js&3.0.0pr2/build/oop/oop-min.js&3.0.0pr2/build/event/event-min.js&3.0.0pr2/build/dom/dom-min.js&3.0.0pr2/build/node/node-min.js"/>

      You can see that "json-min.js" is being requested TWICE; moreover, it's not cached because the combo handler uses different urls.

      So I'm giving just a very simple example, but looking to other components, this could grow and becomes big.

      This was already a problem in YUI Loader 2.x, I thought it was going to be fixed and improved in YUI 3.x...

      I thought that YUI could check what has already been requested and not request it again. Are you guys aware of this problem? Is this problem going to be fixed?
    • Adam Moore
      ... Normally you should use a single instance, and request what you need as you go -- this works fine. The issue you are demonstrating here is known, and is
      Message 2 of 4 , Apr 1, 2009
      • 0 Attachment
        On Wed, Apr 01, 2009 at 06:50:26PM -0000, renatoiwa wrote:
        > Hey guys,
        >
        > I'm enjoying the YUI 3.x but there's something that is annoying me and that's one of the main reasons I believe it will be a problem for everyone who will use the YUI with loader...
        >
        > So, here's the problem.
        >
        > If I understood correctly, we MUST run commands under this syntax:
        >
        > YUI.use("node"),function(Y){
        > // COMMANDS
        > });
        >
        > I know we have the option to load components through the traditional process by adding the components to the requests of the page and then using:
        >
        > YUI.use("*"),function(Y){
        > });
        >
        > Ok, but I really want to use the load method.
        > YUI uses the benefit of combo handler. But what I think it will be a problem is that combo handler doesn't have control of caching the files because the URL will always be changing, as it is dynamic and LOADER does not check if I already have requested a component or not.
        >
        > Let me give you guys a very simple example:
        >
        > <script type="text/javascript">
        > YUI().use("json",function(Y){
        > Y.log("Test 1");
        > });
        >
        > YUI().use("json","node",function(Y){
        > Y.log("Test 2");
        > });
        > </script>

        Normally you should use a single instance, and request what you need as
        you go -- this works fine. The issue you are demonstrating here is
        known, and is being addressed:

        http://yuilibrary.com/projects/yui3/ticket/2525940

        -Adam

        >
        > And here's what YUI will request dynamically:
        >
        > <script id="yui__dyn_0" type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/combo?3.0.0pr2/build/json/json-min.js"/>
        >
        > <script id="yui__dyn_0" type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/combo?3.0.0pr2/build/json/json-min.js&3.0.0pr2/build/oop/oop-min.js&3.0.0pr2/build/event/event-min.js&3.0.0pr2/build/dom/dom-min.js&3.0.0pr2/build/node/node-min.js"/>
        >
        > You can see that "json-min.js" is being requested TWICE; moreover, it's not cached because the combo handler uses different urls.
        >
        > So I'm giving just a very simple example, but looking to other components, this could grow and becomes big.
        >
        > This was already a problem in YUI Loader 2.x, I thought it was going to be fixed and improved in YUI 3.x...
        >
        > I thought that YUI could check what has already been requested and not request it again. Are you guys aware of this problem? Is this problem going to be fixed?
        >

        --
      • Caridy Patino
        Hey Renato, As you mentioned, this issue is also affecting yui2.x, and we have been discussing it for a while. In your example you have two subsequence
        Message 3 of 4 , Apr 1, 2009
        • 0 Attachment
          Hey Renato,

          As you mentioned, this issue is also affecting yui2.x, and we have been discussing it for a while.

          In your example you have two subsequence request, so, YUI Loader doesn't waiting until the first request finish to start the second one, and because of that json is not ready (registered) yet when the second instance get executed. As a result, YUI Loader will try to include json in the second combo url as well.

          The solution for that will be a queue, and YUI loader should load one set of requirements at a time.

          Internally, I solved that problem on YRegions (on top of YUI2.x) using a queue that wraps the yui loader processes. According to Adam, this should be solved in the near future before the GA.

          btw, I'm glad you just start posting here... :-)

          Best Regards,
          Caridy

          --- In yui3@yahoogroups.com, "renatoiwa" <renatoiwa@...> wrote:
          >
          > Hey guys,
          >
          > I'm enjoying the YUI 3.x but there's something that is annoying me and that's one of the main reasons I believe it will be a problem for everyone who will use the YUI with loader...
          >
          > So, here's the problem.
          >
          > If I understood correctly, we MUST run commands under this syntax:
          >
          > YUI.use("node"),function(Y){
          > // COMMANDS
          > });
          >
          > I know we have the option to load components through the traditional process by adding the components to the requests of the page and then using:
          >
          > YUI.use("*"),function(Y){
          > });
          >
          > Ok, but I really want to use the load method.
          > YUI uses the benefit of combo handler. But what I think it will be a problem is that combo handler doesn't have control of caching the files because the URL will always be changing, as it is dynamic and LOADER does not check if I already have requested a component or not.
          >
          > Let me give you guys a very simple example:
          >
          > <script type="text/javascript">
          > YUI().use("json",function(Y){
          > Y.log("Test 1");
          > });
          >
          > YUI().use("json","node",function(Y){
          > Y.log("Test 2");
          > });
          > </script>
          >
          > And here's what YUI will request dynamically:
          >
          > <script id="yui__dyn_0" type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/combo?3.0.0pr2/build/json/json-min.js"/>
          >
          > <script id="yui__dyn_0" type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/combo?3.0.0pr2/build/json/json-min.js&3.0.0pr2/build/oop/oop-min.js&3.0.0pr2/build/event/event-min.js&3.0.0pr2/build/dom/dom-min.js&3.0.0pr2/build/node/node-min.js"/>
          >
          > You can see that "json-min.js" is being requested TWICE; moreover, it's not cached because the combo handler uses different urls.
          >
          > So I'm giving just a very simple example, but looking to other components, this could grow and becomes big.
          >
          > This was already a problem in YUI Loader 2.x, I thought it was going to be fixed and improved in YUI 3.x...
          >
          > I thought that YUI could check what has already been requested and not request it again. Are you guys aware of this problem? Is this problem going to be fixed?
          >
        • Caridy Patino
          Ops, Adam is always faster than myself... hehehehe Best Regards, Caridy
          Message 4 of 4 , Apr 1, 2009
          • 0 Attachment
            Ops, Adam is always faster than myself... hehehehe

            Best Regards,
            Caridy

            --- In yui3@yahoogroups.com, Adam Moore <adamoore@...> wrote:
            >
            > On Wed, Apr 01, 2009 at 06:50:26PM -0000, renatoiwa wrote:
            > > Hey guys,
            > >
            > > I'm enjoying the YUI 3.x but there's something that is annoying me and that's one of the main reasons I believe it will be a problem for everyone who will use the YUI with loader...
            > >
            > > So, here's the problem.
            > >
            > > If I understood correctly, we MUST run commands under this syntax:
            > >
            > > YUI.use("node"),function(Y){
            > > // COMMANDS
            > > });
            > >
            > > I know we have the option to load components through the traditional process by adding the components to the requests of the page and then using:
            > >
            > > YUI.use("*"),function(Y){
            > > });
            > >
            > > Ok, but I really want to use the load method.
            > > YUI uses the benefit of combo handler. But what I think it will be a problem is that combo handler doesn't have control of caching the files because the URL will always be changing, as it is dynamic and LOADER does not check if I already have requested a component or not.
            > >
            > > Let me give you guys a very simple example:
            > >
            > > <script type="text/javascript">
            > > YUI().use("json",function(Y){
            > > Y.log("Test 1");
            > > });
            > >
            > > YUI().use("json","node",function(Y){
            > > Y.log("Test 2");
            > > });
            > > </script>
            >
            > Normally you should use a single instance, and request what you need as
            > you go -- this works fine. The issue you are demonstrating here is
            > known, and is being addressed:
            >
            > http://yuilibrary.com/projects/yui3/ticket/2525940
            >
            > -Adam
            >
            > >
            > > And here's what YUI will request dynamically:
            > >
            > > <script id="yui__dyn_0" type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/combo?3.0.0pr2/build/json/json-min.js"/>
            > >
            > > <script id="yui__dyn_0" type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/combo?3.0.0pr2/build/json/json-min.js&3.0.0pr2/build/oop/oop-min.js&3.0.0pr2/build/event/event-min.js&3.0.0pr2/build/dom/dom-min.js&3.0.0pr2/build/node/node-min.js"/>
            > >
            > > You can see that "json-min.js" is being requested TWICE; moreover, it's not cached because the combo handler uses different urls.
            > >
            > > So I'm giving just a very simple example, but looking to other components, this could grow and becomes big.
            > >
            > > This was already a problem in YUI Loader 2.x, I thought it was going to be fixed and improved in YUI 3.x...
            > >
            > > I thought that YUI could check what has already been requested and not request it again. Are you guys aware of this problem? Is this problem going to be fixed?
            > >
            >
            > --
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.