Jquery Google CDN not recognised when loaded?

170 views Asked by At

I have been trying to load the Jquery 3.1.1 Google CDN using Modernizr, throught the following code:

Modernizr.load([
        {
            load: "//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.js",
            complete: function () {
                if(!window.jQuery){
                    Modernizr.load("_js/jquery-3.1.1.min.js");
                }
            }
        },

I have correctly installed Modernizr, and I am certain that the api is correct, yet it will not load, and the console say's that it can't find it. I would appreciate it if you could suggest a solution.

Thanks,
Milo

(Update: I am using Modernizr 2.8, so it supports Modernizr.load)

1

There are 1 answers

0
Thulasiram On
Note: Modernizr <=2.7.1 are working fine with load method call.
Except: 2.5b verison alone.

Modernizr.load({
  load: [
    'https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js'    
             ],
  complete: function () {
    if (!window.jQuery) {
      Modernizr.load({
        load: [ '_js/jquery-3.1.1.min.js' ],
        complete : function(){ 
                alert('Loaded jQuery: _js/jquery-3.1.1.min.js');                    
        }});
    } else {
    alert('Loaded jQuery: https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js');
    }
  }
});

Demo