문제

I'm using RequireJs for structuring my JavaScript code. Also, I'm using a lot of CSS3 and I use "Modernizr w/ YepNope" + x number of css3 polyfills.

I understand "Modernizr w/ YepNope" and RequireJs are both Resource Loaders. Since they are both resource loaders is it a bad idea to use both of them in the same project?

So, basically I'm asking, is it a bad idea to use:

  • Require.js
  • Modernizr.js w/ YepNope.js

In the same page?

도움이 되었습니까?

해결책

As long as you don't load RequireJS modules via YepNope it is ok to use both. Otherwise you could encounter this issue according to the RequireJS doc : http://requirejs.org/docs/errors.html#mismatch

And since you load stuff outside RequireJS, i.e. an API polyfill, the only way your modules could use those polyfills would be to make the initial require() call within the complete() callback of YepNope. But IMHO it gets a bit clunky...

다른 팁

Summary: Respond.js, (which is great with jQuery Mobile), is based on css3 media queries, so if polyfills is all you need, you probably do not 'need' resource loaders.

I cannot speak for YepNopejs, but since respond.js is listed in Modernizer, it seems redundant.

Modernizer, if used, should determine whether or not respond.js is loaded.

Modernizer will conditionally load the scripts, including respond.js, client-side based on feature detects. Supported scripts (which do not currently include YepNope) at

https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top