Download jQuery via modernizr

Just by launching a new HTML5 project and using modernizr.js

I noticed on the modernizr docs page that you can use the following:

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

So in my HTML this is:

 <script src="scripts/modernizr-2.0.6.js"></script> <script> Modernizr.load([ { load: 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', complete: function () { if ( !window.jQuery ) { Modernizr.load('scripts/jquery-1.6.1.min.js'); } } } ]); </script> 

But looking at firebug, jquery loading fails.

Did I miss something obvious here?

Cheers, Adi

+4
source share
3 answers

Modernizr is a small library, and it loads and runs quickly, and yes, it will load scripts in parallel, so it's a good idea to use it. About your error, remove https: from the URL and try, as in the example.

+8
source

Since I had the same problem and Adi developed it, this is why Modernizer.load will not work for some people:

Hi, ToyDaVirus. It turns out that the problem is that the development version does not use the bootloader. On the top in the comments was "* Modernizr has an additional (not included) conditional resource loader called Modernizr.load () based on Yepnope.js (yepnopejs.com). In order to get an assembly that includes Modernizr.load (), as well as how to choose which tests include, go to www.modernizr.com/download/ "So easy to download from there, and all this is good :)

+1
source

Enter the code below

 Modernizr.load([ { test: Modernizr.mq('(min-device-width: 320px) and (max-device-width: 728px)'), yep : ['mob.css', 'jquery.mobile-1.1.0.css', 'jquery.mobile-1.1.0.js'], nope : 'pc.css' } ]); 

this way you can upload multiple files like css, js

0
source

All Articles