yepnope

Modernizr.load callback executing before loaded script

两盒软妹~` 提交于 2020-01-16 04:00:10
问题 At a certain point on my javascript I have the following (using Modernizr 2.6.2): Modernizr.load([{ load: '/path/file.js', complete: function () { //do stuff } }]); It works great most of the time, except on IE8, about 1 time out of 3 it executes the callback first then the script being loaded. I am adding a break point on the callback and another inside file.js. Both scripts are being executed, just swapping the order at times. I tried to isolate and reproduce the error, but I couldn't. It

Modernizr - Which scripts get loaded asynchronously?

半世苍凉 提交于 2020-01-12 22:31:17
问题 I have the following: Modernizr.load([ { load : '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js', complete : function () { if ( !window.jQuery ){ Modernizr.load('/js/jquery-1.6.2.min.js'); } } }, { load : ["/js/someplugin.js", "/js/anotherplugin.js"], complete : function() { // do some stuff } }, { load: ('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js' } ]}; I read that Modernizr loads scripts Asyncronously. But in the above example, which ones

How to detect if Media Queries are present using Modernizr

妖精的绣舞 提交于 2019-12-30 03:49:10
问题 I'm trying to detect whether media queries are present using Modernizr 2, then loading in respond.js if appropriate. I've put this in my script.js file... Modernizr.load({ test: Modernizr.mq, yep : '', nope: 'mylibs/respond.js' }); What am I doing wrong? I'm really surprised there isn't an example of how to do this with Media Queries on the Modernizr site. Here is the version of Modernizr I'm using... http://www.modernizr.com/download/#-backgroundsize-borderradius-boxshadow-iepp-respond-mq

YepNope key value pairs not executing as expected

时间秒杀一切 提交于 2019-12-24 05:22:09
问题 I am starting to learn YepNope and have a script like such: yepnope([ { load: 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', }, { test: true, yep: { 'jquery-ui' : 'js/jquery-ui.js', 'jquery-expandable' : 'js/jquery.expandable.js', 'triggers' : 'js/triggers.js', 'prettify' : 'js/prettify/prettify.js' }, callback: { 'prettify': function (url, result, key) { console.log(key + ' loaded ' + result); prettyPrint(); } } } ]); I only need a callback for prettify. However running

Load external Google Fonts stylesheet with YepNope/Modernizr

耗尽温柔 提交于 2019-12-21 22:05:17
问题 I'm trying to load a dynamically generated Google Font stylesheet using Modernizr (YepNope) but always get this error: Uncaught SyntaxError: Unexpected token ILLEGAL (css:1) My stylesheet looks like this: http://fonts.googleapis.com/css?family=Holtwood+One+SC and I'm calling it via Modernizr.load({ load: ['css!http://fonts.googleapis.com/cssfamily=Holtwood+One+SC|Terminal+Dosis:700'], callback: function (url, result, key) { console.log('loaded...!'); } }); The website says this but for some

Alternatives to YepNope and LabJS

不羁岁月 提交于 2019-12-21 02:28:10
问题 I am wanting to load javascript and css files via a resource loader. I was originally using LabJs but I found YepNope more elegant and easier to work with in my scenario. However I am finding it devastatingly slow, which is odd as apparently it is comparable to LabJs in speed on most things. One thing I do have are Etags which I am sure will slow everything down as its still requesting from the server rather than just working off the client cache. Anyway there isnt much outside of the main

jQuery.getScript vs yepnope performance

别说谁变了你拦得住时间么 提交于 2019-12-12 06:36:25
问题 I googled quite a lot looking for the answer to this question but didn't find anything. Aside of additionnal functionalities offered by a script loader like yepnope, is it going to give me better performance and better cache management than jQuery.getScript? Thanks in advance, Simon 回答1: In principle, their functionally the same. The biggest gain you get from something like yepnope is integrated conditional loading. Whereas, with $.getScript, you'd have to do any requisite boolean checks

Execute callback after modernizr/yepnope has loaded all files

為{幸葍}努か 提交于 2019-12-11 21:23:40
问题 I have a number of test conditions and files to load before I run the follow up scripts on my page. Is there a way to fire a callback after ALL my files are loaded? The following is suggested by this post and communicates my intent but does not actually work. The function in the complete is firing before 1.js or 2.js has finished loading. Modernizr.load([ { test: App.isSmallScreen, yep: '1.js', nope: '2.js' }, { test: App.isTouch, yep: '3.js' }, { test: Modernizer.csstransitions, nope:4.js },

Modernizr load [A, B] seems to execute B before A, how is this possible?

此生再无相见时 提交于 2019-12-11 02:16:03
问题 Modernizr.load({ both: [a, b] }) seems to executes b before a but that's not how Modernizr is supposed to work? "yepnope.js [used by Modernizr] always executes things in the order they are listed" Modernizr versions 2.5.3 and 2.6.2. I'm loading angular.js and angular-sanitize.js like so: Modernizr.load({ both: [ cdnDir + 'angular.js', cdnDir + 'angular-sanitize.js', d.i.assetsUrlPathStart + 'debiki-dashbar.js'], complete: bootstrapAngular }) However, infrequently, angular-sanitize.js dies

Multiple conditions with yepnope

不打扰是莪最后的温柔 提交于 2019-12-10 13:27:54
问题 I use yepnope.js as a resource loaded. I want to execute code in my JS module only when all the dependencies for that module have been loaded. I do not want to load JS dependencies that already been loaded. Suppose, I have dependencies D1.js and D2.js. I tried yepnope({ load: ['D1.js', 'D2.js], complete: function() { //execute my code here } }); That works, but, resources are loaded every time, even if they were already loaded before. If I do multiple tests like that: yepnope([{ test: $().d1,