Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if jQuery or mooTools are loaded

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 ?

like image 444
hsz Avatar asked Jul 16 '10 09:07

hsz


People also ask

How do you check is jQuery loaded or not?

You can just type window. jQuery in Console . If it return a function(e,n) ... Then it is confirmed that the jquery is loaded and working successfully. Save this answer.

Is not a function error jQuery?

on if not a function" jQuery error occurs for 2 main reasons: Loading an old version of the jQuery library that doesn't support the on function. Loading a library that overrides the value of the dollar sign $ variable.


1 Answers

Both are adding global varibles with its names:

MooTools and jQuery

So just check:

if(window.MooTools) or if(window.jQuery)
like image 164
fantactuka Avatar answered Sep 28 '22 01:09

fantactuka