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

前端 未结 2 1513
一个人的身影
一个人的身影 2020-12-19 15:18

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 n

2条回答
  •  無奈伤痛
    2020-12-19 15:55

    Have a look here for scripts: https://stackoverflow.com/a/7719185 — no jQuery required. (Note that there's a shorter Promise example a bit down in the answer; don't stop reading after the first example (like I did)).

    And here for CSS: loadCSS: https://github.com/filamentgroup/loadCSS/blob/master/src/loadCSS.js

    — this is, in a way, even better than YepNope.js, if you don't need any of its features except for just loading stuff + callback. Because the stuff linked above, is smaller (smaller min.js.gz) than yepnope.js.

    (And can combine with Modernizr like mhk showed in his answer.)

提交回复
热议问题