javascriptjqueryloaded

jQuery doesn't load in firefox


I've got a simple HTML file in which jQuery is included. In Safari it works but in Firefox it doesn't load. And when I use $ I get the following error message in firefox:

ReferenceError: $ is not defined

<!doctype html>
<html>
<head>

</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" type='text/javascript' integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script>
    if (window.jQuery) {
        alert("loaded");
    } else {
        alert("not loaded");
    }
</script>
</body>
</html>

Solution

  • Most likely the integrity attribute value is not matching with the hash value of the script. Could you please check in console window if you are getting any error?

    I have figured out the root cause. Based on caniuse site, safari does NOT implement this feature and hence you don't see the problem on safari. Same case for IE and Edge. Please see below: enter image description here