What are the best strategies for using multiple AJAX libraries?

What experience can you share about using multiple AJAX libraries?

Prototype has some useful features, some of jQuery, Yahoo library, etc. Is it possible to include all libraries and use what you want from each, do they usually play well with namespaces, etc. For the sake of speed, is there a practical limit to the size / number of libraries to include, or is it insignificant? Are there couples that work especially well together (like Prototype / Scriptaculous) or couples that don't?

+6
jquery prototypejs ajax yui scriptaculous
source share
7 answers

You can use all of these libraries, but I highly recommend against this. Downloading and executing this JavaScript is likely to overwhelm the browser and slow down the user experience. It would be much better from the point of view of the user and the developer to choose one. Less context / architecture switching and less code to support.

Like the other answers, most do not conflict.

See Yahoo! Exceptional performance for more information.

+9
source share

You can use the Google AJAX Libraries API . It provides a common distribution network and download architecture for jQuery, prototype, script.aculo.us, MooTools and dojo

+4
source share

YUI fits quite heavily in names, so it should not interfere with other libraries.

As already mentioned, you can run jQuery in conflict-free mode.

The prototype has some problems playing pretty well with other libraries because it (or it used) modifies basic objects like Array . Protosafe is trying to solve these problems.

Script.aculo.us is just a widget library that sits on top of the prototype, so the two should clearly combine well.

All this means that you can use YUI, jQuery, Prototype, and Script.aculo.us in your application, but you may find that using one library makes maintenance much easier.

+3
source share

I am also a supporter of jQuery, so I apologize for not knowing others, but ...

What makes jQuery so wonderful is its conflict-free mode, so for example, you would do:

 $('#foobar').whatever(); 

In conflict free mode, you will do the following:

 var jq = jQuery.noConflict(); jq('#foobar').whatever(); 

Nothing to worry about. I would suggest that the prototype offers a similar feature, as well as Yahoo.

But anyway, I would not want to protect jQuery too much and made people go crazy, but no matter which library you choose, I think that they can do almost everything you need. Especially think about the benefits not to learn three different libraries.

All three must be capable. Choose the one you like best and expand it. :)

+2
source share

I am using jQuery and the javascript version only for the Microsof ajax toolkit version nearby in the project right now.

I think I'm going to go with jQuery and end up uninstalling Microsoft. I am very new to jQuery, but the more I learn about it, the more I'm in love.

+1
source share

The best strategy is not to use multiple libraries . It is tempting to want to throw more libraries into the problem, but it is inefficient, error prone and makes your code more complicated for others.

In most cases, you should avoid using multiple libraries, understanding your problem domain, and which library will help you best solve this problem. There are also many plugins and extensions for all of these libraries.

For example, jQuery supports cross-domain JSONP calls right out of the box and has a beautiful widget library in JQueryUI, Prototype does not.

 $.getJSON('http://anothersite.com/mashup.json?callback=?', function(data) { }); 

The prototype has really good OO support and easily moves around the DOM, but it lacks some of the cross-domain functions needed to create widgets and mashup.

 var Foo = Class.create({ initialize: function(name) { this.name = name; } }); var Bar = Class.create(Foo, { initialize: function($super, name) { $super(name); } }); 

Mootools has great effects, good OO support, really solid widgets and cross-domain query, but (and this may just be my impression), the development community is not as collaborative and social with the world community (outside mootools) as other communities (such so there was a prototype). This may be the result of their main developer (s) living outside the US, and thus cannot attend so many conferences and participate in the wider community. I would not let this completely restrain you, but this is something to keep in mind.

+1
source share

Ruby on Rails by default uses both a prototype and Scriptaculous, as it slightly overlaps between them. In addition, I also used juicy fragments and never experienced any problems. Download time is a problem, but libraries are usually cached, so it only loads on the first page.

0
source share

All Articles