Reputation: 2404
My application previously heavily using Modernizr to load script and shim, i have been stuck for a while with a problem on loading Angular JS. Loading using Modernizr right after JQuery will produce an error; No module : (module name);
But when i move JQuery & Angular on top before script loading, line which using JQuery(inside angular controller script) will fail although it have been load before the angular script. I'm using below script to defer inline script in after modernizr loaded, it will execute after modenizr finished loading all the scripts. When i comment to off the script loading line, everything is fine but the inline script on current page will failed.
docready=[],$=function(){return{ready:function(fn){docready.push(fn)}}},
Upvotes: 2
Views: 2810
Reputation: 2404
I solve this problem by creating a simple deferred function as push it to array.
var _a = {ready: function(fn){ _as.push(fn);}}
Replacing normal $(document).ready to below syntax.
_a.ready(function(){
Then calling this function after modernizr complete loading all the require JS.
for(n in _as) _as[n]();
Thats all.
Upvotes: 1