yepnope

Is Modernizr.load (Yepnope) meant to be used in the <head>

别说谁变了你拦得住时间么 提交于 2019-12-10 09:34:59
问题 Since Modernizr.load and Yepnope are asynchronous loaders, is it better performance-wise to use them in the <head> or at the end of the page? 回答1: It depends on the resources being loaded. See this thread where Yepnope developer Alex Sexton says to combine all the resources into one call to the loader. In practice, if any of the resources you want to load with Modernizr.load or Yepnope affect what the user sees or needs when the page first loads, then IMO in most cases you want to call the

Modernizr testing

喜夏-厌秋 提交于 2019-12-07 12:52:00
问题 How come this alerts both, yes and false? Modernizr.load([ { test: Modernizr.cssgradients, yep: alert('Supports it!'), nope: alert('Oh, damn! This browser sucks!') } ]); I'm using the latest chrome on OS X. 回答1: Because you're calling alert() directly there, and the result from alert() (always undefined ) is assigned to the yep and nope properties. You need to wrap alert() in a function and assign that function instead: Modernizr.load([ { test: Modernizr.cssgradients, yep: function () { alert

How to check if an asynchronously loaded script has finished loading in javascript

白昼怎懂夜的黑 提交于 2019-12-07 03:43:44
问题 Using javascript to asynchronously download another javascript file. I understand that this can be done by inserting a new script tag onto the page with the src attribute set to the file url. I also need to run some code when the script is finished downloading. I've been using yepnope for this and they provide "callbacks" that execute when the script has finished downloading and executing. How is this accomplished? Thanks! 回答1: Most JS loaders do this via injecting an <script> tag to the DOM,

Using yepnope, how can I know if a css resource was loaded successfully?

南楼画角 提交于 2019-12-06 16:00:21
问题 I'm developping a webapp for internal use in a company with a strict (and evolving) firewall. I'm using yepnope.js / Modernizr.load to load js and css files from CDN with fallbacks. But how do I know if a css was loaded successfully ? Is there a way to test successful loading and activation of a css ? 回答1: Thanks to the hint from @Morpheus, here is a solution : First, in order to not depend on anything (jQuery, etc.) we need to define 2 functions : One to get the css property of an element :

Yepnope & Modernizr screen.width Conditions

╄→尐↘猪︶ㄣ 提交于 2019-12-06 08:15:27
问题 I am trying to (locally) use Yepnope with Modernizr to load CSS & JS Files. So I can manage the files better, and code easily. This is the currently layout: Modernizr.load([ { test: Modernizr.mq('all and (max-width: 1070px)'), yep: '/css/smartdevice.css','/js/smartdevice.js', } , { test: Modernizr.mq('all and (min-width: 481px) and (max-width: 1069px)'), yep: '/css/tablet.css','/js/tablet.js', }, { test: Modernizr.mq('all and (max-width: 1070px)'), yep: '/css/screen.css','/js/screen.js', } ])

Modernizr testing

五迷三道 提交于 2019-12-06 02:39:32
How come this alerts both, yes and false? Modernizr.load([ { test: Modernizr.cssgradients, yep: alert('Supports it!'), nope: alert('Oh, damn! This browser sucks!') } ]); I'm using the latest chrome on OS X. Because you're calling alert() directly there, and the result from alert() (always undefined ) is assigned to the yep and nope properties. You need to wrap alert() in a function and assign that function instead: Modernizr.load([ { test: Modernizr.cssgradients, yep: function () { alert('Supports it!') }, nope: function () { alert('Oh, damn! This browser sucks!') } } ]); This still won't work

Is Modernizr.load (Yepnope) meant to be used in the <head>

夙愿已清 提交于 2019-12-05 17:11:38
Since Modernizr.load and Yepnope are asynchronous loaders, is it better performance-wise to use them in the <head> or at the end of the page? It depends on the resources being loaded. See this thread where Yepnope developer Alex Sexton says to combine all the resources into one call to the loader. In practice, if any of the resources you want to load with Modernizr.load or Yepnope affect what the user sees or needs when the page first loads, then IMO in most cases you want to call the loader after your critical resources but still in the <head> . Comment from yeapnope developer: It's better at

Using yepnope, how can I know if a css resource was loaded successfully?

╄→гoц情女王★ 提交于 2019-12-04 19:42:24
I'm developping a webapp for internal use in a company with a strict (and evolving) firewall. I'm using yepnope.js / Modernizr.load to load js and css files from CDN with fallbacks. But how do I know if a css was loaded successfully ? Is there a way to test successful loading and activation of a css ? Offirmo Thanks to the hint from @Morpheus, here is a solution : First, in order to not depend on anything (jQuery, etc.) we need to define 2 functions : One to get the css property of an element : from http://robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/ function getStyle(oElm,

Load external Google Fonts stylesheet with YepNope/Modernizr

我只是一个虾纸丫 提交于 2019-12-04 17:25:33
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 reason it just won't work. I think the resource is parsed as a script file and that's what cause the

Yepnope & Modernizr screen.width Conditions

别来无恙 提交于 2019-12-04 14:27:41
I am trying to (locally) use Yepnope with Modernizr to load CSS & JS Files. So I can manage the files better, and code easily. This is the currently layout: Modernizr.load([ { test: Modernizr.mq('all and (max-width: 1070px)'), yep: '/css/smartdevice.css','/js/smartdevice.js', } , { test: Modernizr.mq('all and (min-width: 481px) and (max-width: 1069px)'), yep: '/css/tablet.css','/js/tablet.js', }, { test: Modernizr.mq('all and (max-width: 1070px)'), yep: '/css/screen.css','/js/screen.js', } ]); The I am fairly new to JS but I have used jQuery on may occasions. However they all load at once, is