YUILibrary - Open source JavaScript and CSS for building richly interactive software.
Fork YUI on GitHub
  [ 9 posts ]

jbchurn

  • Username: jbchurn
  • Joined: Fri Aug 21, 2009 12:42 am
  • Posts: 67
  • Offline
  • Profile
Tags:

Does YUI Loader "require" config needs to preserve its seq?

Post Posted: Sun Nov 22, 2009 4:53 pm
+0-
Hi,

Does the array of components in the "require" of YUI Loader config needs to preserve the sequence?

Thanks.

Caridy Patino

YUI Contributor

  • Username: caridy
  • Joined: Mon Dec 08, 2008 5:40 pm
  • Posts: 349
  • Location: Miami, FL
  • Twitter: caridy
  • GitHub: caridy
  • Gists: caridy
  • IRC: caridy
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: Does YUI Loader "require" config needs to preserve its seq?

Post Posted: Sun Nov 22, 2009 6:31 pm
+0-
No, but if they have some dependencies between them, you have to specify those dependencies in the definition.

Best Regards,
Caridy

jbchurn

  • Username: jbchurn
  • Joined: Fri Aug 21, 2009 12:42 am
  • Posts: 67
  • Offline
  • Profile

Re: Does YUI Loader "require" config needs to preserve its seq?

Post Posted: Sun Nov 22, 2009 9:58 pm
+0-
Hi,

Can you elaborate on what do you mean by if they have dependency, then have to specify in the definition? since your feedback at first was no need to preserve the sequence of its array.

Just in case my question was confusing earlier, I actually would like to know if for example, the following sequence of require components are generated from yui dependency configurator:
require: ["button","datatable","paginator"]

In future, if i want to add calendar, can I add "calendar" in any position in the require array?
yui dependency configurator generates the sequence as :
require: ["button","calendar","datatable","paginator"]

Can I specify it like below ?
require: ["button","datatable","paginator","calendar"]

Thanks.

Caridy Patino

YUI Contributor

  • Username: caridy
  • Joined: Mon Dec 08, 2008 5:40 pm
  • Posts: 349
  • Location: Miami, FL
  • Twitter: caridy
  • GitHub: caridy
  • Gists: caridy
  • IRC: caridy
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: Does YUI Loader "require" config needs to preserve its seq?

Post Posted: Sun Nov 22, 2009 10:17 pm
+0-
The answer is yes, it doesn't matter in which order you specify the requirements, the loader will compute the request in the same way.

Best Regards,
Caridy

Caridy Patino

YUI Contributor

  • Username: caridy
  • Joined: Mon Dec 08, 2008 5:40 pm
  • Posts: 349
  • Location: Miami, FL
  • Twitter: caridy
  • GitHub: caridy
  • Gists: caridy
  • IRC: caridy
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: Does YUI Loader "require" config needs to preserve its seq?

Post Posted: Mon Nov 23, 2009 9:32 am
+0-
Oh, btw, I mentioned custom definition, in case you need to define a custom module with a dependency represented by another custom module.

Best Regards,
Caridy

jbchurn

  • Username: jbchurn
  • Joined: Fri Aug 21, 2009 12:42 am
  • Posts: 67
  • Offline
  • Profile
Tags:

Re: Does YUI Loader "require" config needs to preserve its seq?

Post Posted: Wed Nov 25, 2009 1:35 pm
+0-
Hi,

Thanks for info.

Btw, I tested using the built-in Task Manager of Google Chrome to view the memory used for tab. I noticed loading YUI and my js library using YUI Loader will consume a little bit more memory. In my case scenario, about 1MB++. It maybe different for other browser.

But it's more worth the effort for future maintenance to start using YUI Loader right?
Because I see using YUI Loader can avoid introducing errors to a working page on the dependency part, at least we can include stuff in "require" without the need to maintain any dependency order.

Thanks.

Caridy Patino

YUI Contributor

  • Username: caridy
  • Joined: Mon Dec 08, 2008 5:40 pm
  • Posts: 349
  • Location: Miami, FL
  • Twitter: caridy
  • GitHub: caridy
  • Gists: caridy
  • IRC: caridy
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: Does YUI Loader "require" config needs to preserve its seq?

Post Posted: Wed Nov 25, 2009 5:58 pm
+0-
Hello,

Consuming a little bit more memory makes sense in this case because the Loader will have to compute the dependencies, and injecting scripts dynamically. Also because it will be doing some parallel process (loading the scripts and rendering the page), remember that the loader doesn't blocks the loading process just like a normal script tag does.

And yes, the loader is definitely a more elegant solution, easy to maintain, and provides some performance boost in many cases as well.

Best Regards,
Caridy

jbchurn

  • Username: jbchurn
  • Joined: Fri Aug 21, 2009 12:42 am
  • Posts: 67
  • Offline
  • Profile
Tags:

Re: Does YUI Loader "require" config needs to preserve its seq?

Post Posted: Thu Nov 26, 2009 4:07 am
+0-
Some advise for Javascript to be put at the bottom of the page for better performance.

May I know should we put the scripts for yui loader at the page bottom as well?

Please advise.

Thanks.

Caridy Patino

YUI Contributor

  • Username: caridy
  • Joined: Mon Dec 08, 2008 5:40 pm
  • Posts: 349
  • Location: Miami, FL
  • Twitter: caridy
  • GitHub: caridy
  • Gists: caridy
  • IRC: caridy
  • YUI Developer
  • Offline
  • Profile

Re: Does YUI Loader "require" config needs to preserve its seq?

Post Posted: Thu Nov 26, 2009 7:09 am
+0-
Hey,

Putting Javascript blocks at the bottom of the page will definitely help. And the main reason is because JS blocks will block the loading/render process until the JS gets downloaded and executed. This technique provides a good performance boost if you have some big JS scripts to load, or if they are not cacheable for whatever reason.

That said, I will like to clarify that loading yui3 seed (~4k), and probably the bootstrap block to initialize your application (~1k), both cacheable files, should not impact your app in terms of performance during the loading process.

And from the user points of view, they will feel like a fastest experience, because the loader will start loading the necessary modules (defined in the bootstrap) early during the loading process (without blocking the render process).

There are not rules for this, you can try both options for your app, profile both solutions, and see what suit better for your app.

Best Regards,
Caridy
  [ 9 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum