/    Sign up×
Community /Pin to ProfileBookmark

Modernizr.load()/yepnope : Error when loading JQuery before JS plugins

Hi,

I’m using Modernizr to load all of my JS and CSS scripts in a specific order with callbacks functions to manage the dependences.
But I meet a problem with the loading of Bootstrap witch need JQuery.

I have 3 levels of loading :

1) JQuery lib
2) scripts using JQuery but not needing that the document is loaded
3) scripts using JQuery AND needing document loaded

I get the following error in Firbug : TypeError: l is not a function bootstrap.min.js (ligne 4)

It seems that JQuery does not have time to load before Bootstrap.

Does anybody have an idea please? (to resolve this problem or to purpose another solution to make the same thing) Thanks for your help.

The code in head :

[CODE]<script type=”text/javascript” src=”js/modernizr-2.6.1.min.js”></script>

<script type=”text/javascript”>

Modernizr.load([{
load: ‘http://code.jquery.com/jquery-1.10.2.min.js’,
complete: function(){

Modernizr.load([
//scripts using JQuery but not needing that the document is loaded
‘bootstrap/js/bootstrap.min.js’,
‘js/plugins/respond/respond.min.js’,
‘js/plugins/jquery-ui/jquery-ui-1.8.23.custom.min.js’,
‘js/plugins/easing/jquery.easing.1.3.js’,
‘js/plugins/parallax/js/jquery.stellar.min.js’
]);

$(function(){
//scripts using JQuery AND needing document loaded
Modernizr.load([
{
test : Modernizr.touch,
yep : ‘js/plugins/toucheeffect/toucheffects.js’
},{
test : $(‘.camera_wrap’).length,
yep : {
‘js’:’js/plugins/camera/camera.min.js’,
‘css’:’js/plugins/camera/css/camera.css’
},
complete : {
‘js’: function(){
$(‘.camera_wrap’).camera();
console.log(“plugin loaded!”);
}
}
}
]);
});
}
}]);
</script>[/CODE]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@bleubauthorMay 21.2014 — alert(jQuery) at the beginning of the first callback function is OK so I don't understand why Bootrstarp don't run correctly...
Copy linkTweet thisAlerts:
@ShrineDesignsMay 21.2014 — Why are you using modernizr with jQuery and bootstrap?!

Load toucheffects.js unconditionally. Set mouse [U]and[/U] touch events together as recommended here.
Copy linkTweet thisAlerts:
@bleubauthorMay 21.2014 — Thank you for your response.

Why are you using modernizr with jQuery and bootstrap?![/QUOTE]

Modernizr reduces the load speed of my page by respecting the dependences between the scripts and detects the different screen sizes and browser features.

Bootstrap makes my website responsive.

Load toucheffects.js unconditionally. Set mouse [U]and[/U] touch events together as recommended here.[/QUOTE]

Thank you for the link. It was very useful !
×

Success!

Help @bleub spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...