Yojo: Loading YUI with the Dojo loader

James Burke has made a call out for a little bit of collaboration as he discussed Yojo: Loading YUI with the Dojo loader: I like Dojo 0.9, and I think it has a great solution to loading JS modules dynamically. The core of the Dojo loader has been there since the beginning of the project, […]

James Burke has made a call out for a little bit of collaboration as he discussed Yojo: Loading YUI with the Dojo loader:

I like Dojo 0.9, and I think it has a great solution to loading JS modules dynamically. The core of the Dojo loader has been there since the beginning of the project, but with the addition of the xdomain loader, it really shines (disclaimer: I work on the xdomain loader). It allows anyone to use all of Dojo from a CDN without having to download it.

The loader is a great fit for any JavaScript library that has more than a couple of files to load, and where the files can have dependencies on other files. I touched on this topic during my Ajax Experience talk about Dojo’s xdomain loader. This post explores a real-world example: using the Dojo loader to load YUI.

First, a demo. Here is a page that loads the YUI rich-text Editor using the Dojo loader. If you have a DOM inspector tool, you can verify that the modules where loaded by looking at the dynamically created script elements inside the head element.

James talks more about the implementation, and then the call out:

I would like to see YUI and Dojo converge on using the same type of loader for their code. There is a generic need for this functionality, and it would be good to start standardizing on an approach.

Obviously I would like to start with the Dojo loader and the dojo.provide/require approach and make any modifications that YUI might need to fulfill their needs. I am sure the Dojo loader code could use improvements, in particular the xdomain loader. Look at the file. Isn’t that scary? It scares me and I wrote it! Let’s see if we can make it better.

I am also open to other paths if Dojo’s loader does not seem like the way to go. However, I would like some solution that keeps encapsulation and can leverage a build process for optimizations.

This is also an important test case for further YUI/Dojo collaborations. We are solving lots of the same issues, and I think we will serve the Open Web better if we work together rather than separately.

Yahoo!, Yojo, YUI, Dojo

Source:→ ajaxian