Checking if jquery is loaded using Javascript
something is not right
Well, you are using jQuery to check for the presence of jQuery. If jQuery isn't loaded then $()
won't even run at all and your callback won't execute, unless you're using another library and that library happens to share the same $()
syntax.
Remove your $(document).ready()
(use something like window.onload
instead):
window.onload = function() {
if (window.jQuery) {
// jQuery is loaded
alert("Yeah!");
} else {
// jQuery is not loaded
alert("Doesn't Work");
}
}
As per this link:
if (typeof jQuery == 'undefined') {
// jQuery IS NOT loaded, do stuff here.
}
there are a few more in comments of the link as well like,
if (typeof jQuery == 'function') {...}
//or
if (typeof $== 'function') {...}
// or
if (jQuery) {
alert("jquery is loaded");
} else {
alert("Not loaded");
}
Hope this covers most of the good ways to get this thing done!!