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

Re: [ydn-javascript] Multiple loaders don't play well

Expand Messages
  • Adam Moore
    ... A loader instance will know about all YUI script files that are loaded by any loader instance, but it only will know about css files that it loaded. A
    Message 1 of 8 , May 16, 2008
    View Source
    • 0 Attachment
      On Fri, May 09, 2008 at 05:33:04PM -0000, illiphilli wrote:
      > I work in a dynamic environment where it's hard to know what's going
      > to be on the page at any given time. On any one page, there could be
      > a variety of functionality.

      > What I'd had working previously was calling a new loader for every
      > "module chunk" in an attempt to contain functionality. However, when
      > I realized that the separate instantiations of the loaders weren't
      > aware of one another, I'd end up with multiple menu, container or
      > whatever else that was called added to the head of my document.

      A loader instance will know about all YUI script files that are loaded
      by any loader instance, but it only will know about css files that it
      loaded. A single instance can be reused: call require() when you need to
      add an additional module, then insert(), and it will only load the new
      requirements.

      If you need multiple instances to know about all css files and non-YUI
      script files that have been loaded, please fill out a feature request:

      http://developer.yahoo.com/yui/yuiloader/#filingbugs

      Thanks,

      -Adam
    • yaundro
      ... Adam, first of all, thanks for your concern in this topic. ... need to ... in that case, we cannot do parralel loading of multiple modules (of possibly
      Message 2 of 8 , May 18, 2008
      View Source
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, Adam Moore <adamoore@...> wrote:
        >
        > On Fri, May 09, 2008 at 05:33:04PM -0000, illiphilli wrote:
        > > I work in a dynamic environment where it's hard to know what's going
        > > to be on the page at any given time. On any one page, there could be
        > > a variety of functionality.
        >
        > > What I'd had working previously was calling a new loader for every
        > > "module chunk" in an attempt to contain functionality. However, when
        > > I realized that the separate instantiations of the loaders weren't
        > > aware of one another, I'd end up with multiple menu, container or
        > > whatever else that was called added to the head of my document.
        >

        Adam,

        first of all, thanks for your concern in this topic.


        > A loader instance will know about all YUI script files that are loaded
        > by any loader instance, but it only will know about css files that it
        > loaded. A single instance can be reused: call require() when you
        need to
        > add an additional module, then insert(), and it will only load the new
        > requirements.

        in that case, we cannot do parralel loading of multiple modules (of
        possibly different sources) and have one module's callbacks executed
        as soon as that module's files have been included: The loader will
        wait for all scripts/css to be included.


        >
        > If you need multiple instances to know about all css files and non-YUI
        > script files that have been loaded, please fill out a feature request:
        >
        > http://developer.yahoo.com/yui/yuiloader/#filingbugs
        >
        > Thanks,
        >
        > -Adam
        >

        I've posted a feature request there:
        http://sourceforge.net/tracker/index.php?func=detail&aid=1966417&group_id=165715&atid=836479

        That tries to sum up what issue we are having with the loader.

        Best regards,
        Arnaud
      • apinstein
        ... Thanks for this clarification. I am hoping Adam (or anyone else who s got a working best-practice for dynamic environments) can confirm that I m doing
        Message 3 of 8 , Aug 17, 2008
        View Source
        • 0 Attachment
          > > A loader instance will know about all YUI script files that are loaded
          > > by any loader instance, but it only will know about css files that it
          > > loaded. A single instance can be reused: call require() when you
          > need to
          > > add an additional module, then insert(), and it will only load the new
          > > requirements.

          Thanks for this clarification. I am hoping Adam (or anyone else who's got a working best-practice for dynamic environments)
          can confirm that I'm doing things the most correct way...

          I am especially worried about the way I do it currently since you say above that we can re-use a single instance, which I don't
          think used to be true, because I think I tried it previously. However, it seems that the YUILoader infrastructure has matured (I
          started using it really early on).

          This is what I'm doing now (and you can see it in action here: http://phocoa.com/webapp/examples/ajax/tabs/example)

          1. Including yuiloader-beta-min.js in the <head> section.
          2. For each YUI widget added to the page;
          a) Create a new YUILoader instance
          b) require() all needed things for that widget only
          c) call insert()

          I am experiencing multiple loadings of JS and CSS files, which I'd consider bad. It may be part of the reason I'm seeing weird
          behavior in some circumstances on my more complex pages as well...

          Should I be using a singleton now?

          Thanks in advance,
          Alan
        • seanmccleary
          ... Hi, I know this is an old thread, but the above doesn t seem to be true for me. I am using YUI 2.7.0 and the YUI Loader in several places in one page, and
          Message 4 of 8 , Jun 7, 2009
          View Source
          • 0 Attachment
            --- In ydn-javascript@yahoogroups.com, Adam Moore <adamoore@...>
            > A loader instance will know about all YUI script files that are loaded
            > by any loader instance, but it only will know about css files that it

            Hi,

            I know this is an old thread, but the above doesn't seem to be true for me. I am using YUI 2.7.0 and the YUI Loader in several places in one page, and FireBug shows me that, for instance, yahoo-dom-event.js is being loaded several times (by pretty much all of the loader instances).

            If my page has two "modules", and each one creates a YUI container, and uses the YUI loader to do so, then FireBug shows me that "container-min.js" is being requested twice.

            Is this correct? Or am I doing something wrong?

            Sean
          Your message has been successfully submitted and would be delivered to recipients shortly.