In my project I am using jQuery
in client side and mooTools
in admin side.
I would like to be able to write some part of code (google maps functions, etc) which will be common for both of that libraries.
Is it possible to check if jQuery
or mooTools
libraries are loaded and use proper behaviours ?
$(document).ready(function() {});
or window.addEvent('domready', function(){});
$('#id');
or $('id');
$('googleMapLocalize').addEvent('click', function(){});
or $('googleMapLocalize').bind('click', function(){});
What is the best way ?
In my project I am using jQuery
in client side and mooTools
in admin side.
I would like to be able to write some part of code (google maps functions, etc) which will be common for both of that libraries.
Is it possible to check if jQuery
or mooTools
libraries are loaded and use proper behaviours ?
$(document).ready(function() {});
or window.addEvent('domready', function(){});
$('#id');
or $('id');
$('googleMapLocalize').addEvent('click', function(){});
or $('googleMapLocalize').bind('click', function(){});
What is the best way ?
Share Improve this question asked Jul 16, 2010 at 9:05 hszhsz 152k62 gold badges266 silver badges320 bronze badges3 Answers
Reset to default 14Both are adding global varibles with its names:
MooTools and jQuery
So just check:
if(window.MooTools) or if(window.jQuery)
Simple:
if ($ === window.jQuery) alert('$ bound to jQuery');
if ($() === document.id()) alert('$ bound to MooTools');
Should do the trick.
We use typeof for this
if(typeof jQuery !== 'undefined')
or
if(typeof MooTools !== 'undefined')