views:

910

answers:

4

Dear all I am using the code Mootool[1.11.] and JQuery[1.2.6],Its working fine when these are separate. While i am integrating firefox throws (document).ready(){} is not a function. Is any wrong in my concept, What to do to rectify it?.Any help

+1  A: 

Jquery and Mootools both use '$' as a shorthand way of calling their main functions. The jquery team have built in a way to stop this so you can write something like:

jQuery(document).ready(function(){...});

Instead of

$(document).ready(function(){...});

This will let you use jquery and any other javascript library side by side. Read their docuentation on the subject - http://docs.jquery.com/Using_jQuery_with_Other_Libraries

sanchothefat
A: 

In addition to sanchothefat said, you really should try to avoid using two such frameworks together because they essentially do the same thing. If you're not gzipping your Javascript, you're probably sending the user at least 150-200k of JavaScript with just the libraries, nevermind the plugins you're using. Almost anything you do in MooTools can be done in jQuery and vice versa. If you look around, you can probably find scripts that do what you're looking for that have been ported both ways.

VirtuosiMedia
A: 

You can also see the use of .noConlict method of jQuery. I don't know if it'll be usefull in your case...

tanathos
+2  A: 
jQuery.noConflict(); 
jQuery(function($){ 

   $works with jquery here. 
});
$ works with mootools here.

However, that said, I would suggest you ditch the mootools.

Its complete modification of all object prototypes can cause cause jQuerys functions to randomly and unexplainable cause errors, and on top of that, Mootools' modification of all object prototypes ( the Object and Function prototypes are even modified ), have, in my experience, resulted in jQuery performing significantly slower than without, simply for Mootools being on the same page.

Additionally, Mootools is 50kb, jQuery is 25kb ( average numbers , including extensions ) , having them both will drastically slow down page load just for the extra data fetch.

A project I was working was having problems with javascript performance, and I'm talking really serious slowdowns, in seemingly simple code. We migrated to jQuery, and there was no performance gain until we stopped loading the mootools when we'd finished migrating the code, and then as soon as we dropped mootools, the speed came back.

Kent Fredric
Minified and GZipped, MooTools is *not* anywhere close to 50k. It's closer to the low 20's. If you do the same to jQuery, it's 18k.
VirtuosiMedia
Plus you also have the option of including or not including large sections of code which will bring the size down even further depending on what you need.
VirtuosiMedia
+1 to ditching mootools, but really just ditch either one. You are forcing users to download to scripts that repeat a lot of functionality between them. If it's for a particular effect from an example it's almost garaunteed someone's done it with the other js library.
sanchothefat