yepnope

YepNopeJS: callback triggered before tiny JS file is fully loaded

非 Y 不嫁゛ 提交于 2019-12-04 04:33:33
问题 I've got a site which is loading all kinds of external scripts using Modernizr.load (aka YepNopeJS). One of those scripts is a small statistics script (3,5 kB uncompressed) with a very simple callback function: Modernizr.load({ load: 'http://res.xtractor.no/x.js', callback: function() { _pxReg(); } }); _pxReg is simply a function defined in the x.js script. In about 50% of my pages, I receive an error message "Undefined variable: _pxReg" (Opera 12) or "'_pxReg' is undefined" (Internet

Alternatives to YepNope and LabJS

非 Y 不嫁゛ 提交于 2019-12-03 08:53:28
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 YepNope site, and they havent released a new version with the fixes on their issues list in a while, so I

YepNopeJS: callback triggered before tiny JS file is fully loaded

末鹿安然 提交于 2019-12-01 22:57:16
I've got a site which is loading all kinds of external scripts using Modernizr.load (aka YepNopeJS). One of those scripts is a small statistics script (3,5 kB uncompressed) with a very simple callback function: Modernizr.load({ load: 'http://res.xtractor.no/x.js', callback: function() { _pxReg(); } }); _pxReg is simply a function defined in the x.js script. In about 50% of my pages, I receive an error message "Undefined variable: _pxReg" (Opera 12) or "'_pxReg' is undefined" (Internet Explorer 9). Firefox 15 and Chrome 22 never give errors. The error never occurs when reloading a page. This

How to detect if Media Queries are present using Modernizr

大憨熊 提交于 2019-11-30 11:14:38
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-cssclasses-teststyles-testprop-testallprops-prefixes-domprefixes-load That's because !!Modernizr.mq ===

What is causing my scripts to be requested twice while using Modernizr.load (yepnope.js)

泄露秘密 提交于 2019-11-30 00:34:01
问题 I am using yepnope.js to load javascript files dynamically,and I've noticed that my scripts appear to be loaded twice according to Firebug and Webkit Inspector. The problem is that in Firebug's Net panel (Firefox 4 latest), their response is a 200 , not a 304 . It seems to be slower than in Chrome. I have uploaded this video showing the issue. You can see how the files jquery-1.6.1.min.js and libs.js are loaded an extra time. The code I am using to do this is the following, simplified:

How can I use yepnope.js with $(document).ready() effectively?

守給你的承諾、 提交于 2019-11-29 21:53:52
I have been implementing the yepnope script loader as part of the modernizr.js library. I have successfully got jQuery to load and jQuery dependent scripts afterwards. I am new to asynchronous loading of resources, so it's a bit new to me. I have been searching around, but haven't had much luck with the following. My question is what are your opinions on how to effectively replace the functionality of $(document).ready() when working with the yepnope.js framework. My theory was to create a appropriately named function in my base library and then set that variable on my pages to an anonymous

How can I use yepnope.js with $(document).ready() effectively?

久未见 提交于 2019-11-28 17:48:57
问题 I have been implementing the yepnope script loader as part of the modernizr.js library. I have successfully got jQuery to load and jQuery dependent scripts afterwards. I am new to asynchronous loading of resources, so it's a bit new to me. I have been searching around, but haven't had much luck with the following. My question is what are your opinions on how to effectively replace the functionality of $(document).ready() when working with the yepnope.js framework. My theory was to create a

Modernizr.load Deprecated. Yepnope.js Deprecated. Now what?

廉价感情. 提交于 2019-11-28 04:47:34
问题 Prior to Modernizr v3, I was using yepnope.js Modernizr.load and yepnope.js have both been deprecated. How do we conditionally call stylesheets or javascript files now? Example that worked with Modernizr v2.5.3: Modernizr.load({ test: Modernizr['object-fit'], nope: ['./dist/scripts/object-fit.js'], complete: function(){ if (!Modernizr['object-fit']) { jQuery(".poster img").imageScale({ scale: "best-fill", rescaleOnResize: true }); } } }); 回答1: There's a new syntax and the feature names are