Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

loading jQuery via modernizr

Just starting a new HTML5 project and using modernizr.js

I noticed on the modernizr docs page it says 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 I have this:

<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, no jquery is loading.

Am I missing something obvious here?

Cheers, Adi

like image 550
Adi Avatar asked Jan 20 '23 09:01

Adi


1 Answers

Modernizr is a small lib and it gets loaded and executed quickly and yes, it will load scripts in parallel, so good idea to use it. About your error, remove the https: from the url and try as in the example.

like image 85
Troy SK Avatar answered Jan 21 '23 23:01

Troy SK