I am attempting to check if my Jquery Library is loaded onto my HTML page. I am checking to see if it works, but something is not right. Here is what I have:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="/query-1.6.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
if (jQuery) {
// jQuery is loaded
alert("Yeah!");
} else {
// jQuery is not loaded
alert("Doesn't Work");
}
});
</script>
You can do this fast on the console-tab when inspecting your webpage.
E.g:
If it returns
true
it means it's loaded.As per this link:
there are a few more in comments of the link as well like,
and
Hope this covers all good ways to get this thing done!!
Just a small modification that might actually solve the problem:
Instead of
$(document).Ready(function()
usewindow.onload = function()
.A quick way is to run a jQuery command in the developer console. On any browser hit F12 and try to access any of the element .
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 likewindow.onload
instead):