Reputation: 4022
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
Upvotes: 4
Views: 9181
Reputation: 28076
As i had the same problem and Adi worked it out here is the reason why Modernizer.load won't work for some people:
Hi ToyDaVirus. Turns out the issue was the development version doesnt use the loader. At top in the comments was '* Modernizr has an optional (not included) conditional resource loader called Modernizr.load(), based on Yepnope.js (yepnopejs.com). To get a build that includes Modernizr.load(), as well as choosing which tests to include, go to www.modernizr.com/download/' So just download from there and all is fine :)
Upvotes: 1
Reputation: 161
Put below code before
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 load multiple files such as css, js
Upvotes: 0
Reputation: 1289
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.
Upvotes: 8